Beispiel #1
0
        public static void AppendEntranceReqs(Story story, string dungeonName, string[] reqString)
        {
            //if (DungeonManager.Dungeons[dungeonIndex].ScriptList.ContainsKey(2)) {

            StorySegment segment = new StorySegment();

            if (reqString.Length == 1) {
                string req = GetRequirementString(reqString[0].Split(','));
                string start = req.Substring(0, 1).ToLower();
                segment.Action = Enums.StoryAction.Say;
                segment.AddParameter("Text", "Notice: In order to enter " + dungeonName + ", " + start + req.Substring(1, req.Length - 1));
                segment.AddParameter("Mugshot", "-1");
                segment.Parameters.Add("Speed", "0");
                segment.Parameters.Add("PauseLocation", "0");
                story.Segments.Add(segment);
                return;
            } else {

                segment.Action = Enums.StoryAction.Say;
                segment.AddParameter("Text", "Notice: You must meet certain requirements before entering " + dungeonName + ".");
                segment.AddParameter("Mugshot", "-1");
                segment.Parameters.Add("Speed", "0");
                segment.Parameters.Add("PauseLocation", "0");
                story.Segments.Add(segment);
            }

            for (int i = 0; i < reqString.Length; i++) {

                string req = GetRequirementString(reqString[i].Split(','));

                segment = new StorySegment();
                segment.Action = Enums.StoryAction.Say;

                if (i == reqString.Length - 1) {
                    string start = req.Substring(0, 1).ToLower();
                    segment.AddParameter("Text", "Also, " + start + req.Substring(1, req.Length - 1));
                } else {
                    segment.AddParameter("Text", req + "..");
                }

                segment.AddParameter("Mugshot", "-1");
                segment.Parameters.Add("Speed", "0");
                segment.Parameters.Add("PauseLocation", "0");
                story.Segments.Add(segment);
            }

            //} else {
            //	return null;
            //}
        }
Beispiel #2
0
 public static void PlayStory(Client client, Story story)
 {
     if (client.Player.CurrentChapter != null) {
         client.Player.StoryPlaybackCache.Add(story);
     } else {
         if (string.IsNullOrEmpty(story.Name)) {
             story.Name = "Scripted Story";
         }
         client.Player.CurrentChapter = story;
         client.Player.LoadingStory = true;
         Messenger.SendLoadingStoryTo(client);
         Messenger.SendRunStoryTo(client, story);
     }
 }
Beispiel #3
0
        public static void OnTournamentCanceled(Tournament tournament, string reason)
        {
            try {
                Story story = new Story();
                StoryBuilderSegment segment = StoryBuilder.BuildStory();

                StoryBuilder.AppendSaySegment(segment, "The tournament was canceled! " + reason, -1, 0, 0);
                segment.AppendToStory(story);

                for (int i = 0; i < tournament.RegisteredMembers.Count; i++) {
                    StoryManager.PlayStory(tournament.RegisteredMembers[i].Client, story);
                }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: OnTournamentCanceled", Text.Black);
            }
        }
Beispiel #4
0
        public static void OnPlayerRegisteredInTournament(Tournament tournament, TournamentMember member, bool isSpectator)
        {
            try {
                if (member.Client.Player.MapID == MapManager.GenerateMapID(1192)) {
                    if (!isSpectator) {
                        Story story = new Story();
                        StoryBuilderSegment segment = StoryBuilder.BuildStory();

                        StoryBuilder.AppendSaySegment(segment, "Please step into the left door.", -1, 0, 0);
                        StoryBuilder.AppendMovePlayerAction(segment, 9, 1, Enums.Speed.Walking, true);

                        segment.AppendToStory(story);
                        StoryManager.PlayStory(member.Client, story);
                    } else {
                        // Player is a spectator
                        tournament.WarpToHub(member.Client);
                    }
                }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: OnPlayerRegisteredInTournament", Text.Black);
            }
        }
Beispiel #5
0
        public static void OnMissionComplete(Client client, int missionIndex)
        {
            try {
                Story story = new Story();
                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                StoryBuilder.AppendSaySegment(segment, "You have completed a mission!  Return to the mission board to claim your reward.", -1, 0, 0);
                segment.AppendToStory(story);
                StoryManager.PlayStory(client, story);

            } catch (Exception ex) {
                Messenger.AdminMsg("Error: OnMissionComplete", Text.Black);
            }
        }
        public static void LoadStory(int storyNum, MySql database)
        {
            if (stories.Stories.ContainsKey(storyNum) == false)
                stories.Stories.Add(storyNum, new Story(storyNum.ToString()));
            Story story = new Story(storyNum.ToString());

            string query = "SELECT revision, " +
                "name, " +
                "story_start " +
                "FROM story WHERE story.num = \'" + storyNum + "\'";

            DataColumnCollection row = database.RetrieveRow(query);
            if (row != null)
            {
                story.Revision = row["revision"].ValueString.ToInt();
                story.Name = row["name"].ValueString;
                story.StoryStart = row["story_start"].ValueString.ToInt();
            }

            query = "SELECT segment, " +
                "action, " +
                "checkpoint " +
                "FROM story_segment WHERE story_segment.num = \'" + storyNum + "\'";

            List<DataColumnCollection> columnCollections = database.RetrieveRows(query);
            if (columnCollections == null) columnCollections = new List<DataColumnCollection>();
            foreach (DataColumnCollection columnCollection in columnCollections)
            {

                StorySegment segment = new StorySegment();

                int segmentNum = columnCollection["segment"].ValueString.ToInt();

                segment.Action = (Enums.StoryAction)columnCollection["action"].ValueString.ToInt();
                bool isCheckpoint = columnCollection["checkpoint"].ValueString.ToBool();

                string query2 = "SELECT param_key, " +
                    "param_val " +
                    "FROM story_param WHERE story_param.num = \'" + storyNum + "\' AND story_param.segment = \'" + segmentNum + "\'";

                List<DataColumnCollection> columnCollections2 = database.RetrieveRows(query2);
                if (columnCollections2 == null) columnCollections2 = new List<DataColumnCollection>();
                foreach (DataColumnCollection columnCollection2 in columnCollections2)
                {
                    string paramKey = columnCollection2["param_key"].ValueString;
                    string paramVal = columnCollection2["param_val"].ValueString;
                    segment.Parameters.Add(paramKey, paramVal);
                }
                story.Segments.Add(segment);

                if (isCheckpoint)
                {
                    story.ExitAndContinue.Add(segmentNum);
                }
            }

            stories.Stories[storyNum] = story;
        }
Beispiel #7
0
 public void Add(Story story)
 {
     cache.Add(story);
 }
Beispiel #8
0
        public static void ScriptedNpc(ICharacter attacker, string script, int npcNum, IMap map, ICharacter mapNpc)
        {
            //StoryManager.PlayStory(((Recruit)attacker).Owner, 9);
            switch (npcNum) {
                case 4: {//oshawott
                    int shellCount = 0;
                    int saltCount = 0;
                    for (int i = 1; i <= ((Recruit)attacker).Owner.Player.Inventory.Count; i++) {
                        if (((Recruit)attacker).Owner.Player.Inventory[i].Num == 96) {
                            shellCount++;
                        } else if (((Recruit)attacker).Owner.Player.Inventory[i].Num == 102) {
                            saltCount++;
                        }
                    }
                        if (shellCount >= 5 && saltCount >= 5) {
                            Messenger.AskQuestion(((Recruit)attacker).Owner, "ShellBell", "Oh look!  You've got some Shoal Salt and Shoal Shells with you!  Do you want me to make you a Shell Bell?", Pokedex.FindByName("Oshawott").ID);
                        } else {
                            Story story = new Story();
                            StoryBuilderSegment segment = StoryBuilder.BuildStory();
                            StoryBuilder.AppendSaySegment(segment, "Hey... Do you like to collect things on the beach?", Pokedex.FindByName("Oshawott").ID, 0, 0);
                            StoryBuilder.AppendSaySegment(segment, "If you can bring me five Shoal Salts and five Shoal Shells, I can make you a Shell Bell.", Pokedex.FindByName("Oshawott").ID, 0, 0);

                            segment.AppendToStory(story);
                            StoryManager.PlayStory(((Recruit)attacker).Owner, story);
                        }
                    }
                    break;
                case 31: {//chansey

                        //int itemTaken = ((Recruit)attacker).Owner.Player.HasItem(110);
                        //if (((Recruit)attacker).Owner.Player.FindInvSlot(109) > itemTaken || ((Recruit)attacker).Owner.Player.Inventory[itemTaken].Num == 0) {
                        //	itemTaken = ((Recruit)attacker).Owner.Player.FindInvSlot(109);
                        //}
                        //Messenger.PlayerMsg(((Recruit)attacker).Owner, ((Recruit)attacker).Owner.Player.Inventory[itemTaken].Num.ToString(), Text.Black);
                        //if (((Recruit)attacker).Owner.Player.FindInvSlot(131) > itemTaken || ((Recruit)attacker).Owner.Player.Inventory[itemTaken].Num == 0) {
                        //	itemTaken = ((Recruit)attacker).Owner.Player.FindInvSlot(131);
                        //}
                        //Messenger.PlayerMsg(((Recruit)attacker).Owner, itemTaken.ToString(), Text.Black);
                        if (((Recruit)attacker).Owner.Player.HasItem(110) > 0 || ((Recruit)attacker).Owner.Player.HasItem(109) > 0 || ((Recruit)attacker).Owner.Player.HasItem(131) > 0) {
                            Messenger.AskQuestion(((Recruit)attacker).Owner, "TradeEgg", "Will you give us the egg at the bottom of your inventory?", Pokedex.FindByName("Togekiss").ID);
                        } else {
                            Story story = new Story();
                            StoryBuilderSegment segment = StoryBuilder.BuildStory();
                            StoryBuilder.AppendSaySegment(segment, "If you've found an egg and don't know what to do with it, we'll be happy to take it in!  We'll give you a gift for it too!", Pokedex.FindByName("Togekiss").ID, 0, 0);
                            segment.AppendToStory(story);
                            StoryManager.PlayStory(((Recruit)attacker).Owner, story);
                        }
                    }
                    break;
                case 53: {//togetic

                        if (((Recruit)attacker).Owner.Player.HasItem(702) > 0) {
                            Messenger.AskQuestion(((Recruit)attacker).Owner, "RecallEggMove", "Oh my!  A Heart Scale!  Will you let me teach you a random move for it?", Pokedex.FindByName("Togetic").ID);
                        } else {
                            Story story = new Story();
                            StoryBuilderSegment segment = StoryBuilder.BuildStory();
                            StoryBuilder.AppendSaySegment(segment, "Hi!  I'm a move tutor.  If you can find me a Heart Scale, I'll teach someone a move.", Pokedex.FindByName("Togetic").ID, 0, 0);
                            StoryBuilder.AppendSaySegment(segment, "But be warned, I don't know what move you'll get until after I teach it!", Pokedex.FindByName("Togetic").ID, 0, 0);
                            segment.AppendToStory(story);
                            StoryManager.PlayStory(((Recruit)attacker).Owner, story);
                        }
                    }
                    break;
                case 350: {//bronzong
                        List<string> choices = new List<string>();

                        if (((Recruit)attacker).Owner.Player.HasItem(263, true) > 0) {
                            choices.Add(ItemManager.Items[263].Name);
                        }

                        if (((Recruit)attacker).Owner.Player.HasItem(264, true) > 0) {
                            choices.Add(ItemManager.Items[264].Name);
                        }

                        if (((Recruit)attacker).Owner.Player.HasItem(265, true) > 0) {
                            choices.Add(ItemManager.Items[265].Name);
                        }

                        if (((Recruit)attacker).Owner.Player.HasItem(266, true) > 0) {
                            choices.Add(ItemManager.Items[266].Name);
                        }

                        if (choices.Count > 0) {

                            choices.Add("Cancel");

                            Messenger.AskQuestion(((Recruit)attacker).Owner, "LearnTutorMove", "Your shards!  They speak to me!  Give me one, and shall bestow upon you techniques unknown!", Pokedex.FindByName("Bronzong").ID, choices.ToArray());
                        } else {
                            Story story = new Story();
                            StoryBuilderSegment segment = StoryBuilder.BuildStory();
                            StoryBuilder.AppendSaySegment(segment, "Tell me, do you have any shards?  Their history intrigues me...", Pokedex.FindByName("Bronzong").ID, 0, 0);
                            StoryBuilder.AppendSaySegment(segment, "If you can find me any ancient shards, I can teach you a special move.", Pokedex.FindByName("Bronzong").ID, 0, 0);
                            segment.AppendToStory(story);
                            StoryManager.PlayStory(((Recruit)attacker).Owner, story);
                        }
                    }
                    break;
                case 231: {//froslass
                        if (((Recruit)attacker).Owner.Player.FindInvSlot(-1) > 0) {
                            Messenger.PlayerMsg(((Recruit)attacker).Owner, "!", Text.WhiteSmoke);
                            StoryManager.PlayStory(((Recruit)attacker).Owner, 238);
                        } else {
                            Story story = new Story();
                            StoryBuilderSegment segment = StoryBuilder.BuildStory();
                            StoryBuilder.AppendSaySegment(segment, "It seems as though your inventory is full. Come back when you have space!", Pokedex.FindByName("Froslass").ID, 0, 0);
                            segment.AppendToStory(story);
                            StoryManager.PlayStory(((Recruit)attacker).Owner, story);
                        }
                    }
                    break;
                case 62: {
                        StoryManager.PlayStory(((Recruit)attacker).Owner, 273);
                    }
                    break;
                case 67: {
                        StoryManager.PlayStory(((Recruit)attacker).Owner, 651);
                    }
                    break;
                case 68: {
                        StoryManager.PlayStory(((Recruit)attacker).Owner, 650);
                    }
                    break;
                case 69: {
                        StoryManager.PlayStory(((Recruit)attacker).Owner, 652);
                    }
                    break;
                case 1001: {//masquerain
                        StoryManager.PlayStory(((Recruit)attacker).Owner, 133);
                    }
                    break;

            }
        }
Beispiel #9
0
        public static void ScriptedItem(BattleSetup setup, InventoryItem item, int invNum)
        {
            try {
                // Called when a scripted item is used
                ExtraStatus status;

                int itemNum = item.Num;

                int itemEdibility = CheckItemEdibility(itemNum);

                if (itemEdibility == 3 && HasAbility(setup.Attacker, "Harvest") && GetBattleTagArg(setup.BattleTags, "Harvest", 0) == null) {

                    setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " harvested the berry!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                    BattleSetup extraSetup = new BattleSetup();
                    extraSetup.Attacker = setup.Attacker;
                    extraSetup.BattleTags.Add("Harvest");
                    BattleProcessor.HandleItemUse(item, -1, extraSetup);
                    setup.PacketStack.AddHitList(extraSetup.PacketStack);
                }

                switch (itemEdibility) {
                    case 0: {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " used the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 1: {//apple
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic143.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 2: {//gummi
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic145.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 3: {//berry
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic144.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "AteBerry", 0, null, "", setup.PacketStack);
                        }
                        break;
                    case 4: {//seed
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic144.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 5: {//herb
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic144.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 6: {//poffin
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 7: {//bad food
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic143.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 8: {//drink
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " drank the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic142.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                    case 9: {//other consumable
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " ate the " + ItemManager.Items[itemNum].Name + ".", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic143.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                        }
                        break;
                }

                switch (ItemManager.Items[itemNum].Data1) {
                    case 0: {
                        }
                        break;
                    case 1: {
                            //Level-Up
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            int leveldiff = 100 - setup.Attacker.Level;
                            if (leveldiff > ItemManager.Items[itemNum].Data2) {
                                leveldiff = ItemManager.Items[itemNum].Data2;
                            }

                            if (leveldiff < 1) {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            } else {
                                for (int i = 0; i < leveldiff; i++) {
                                    if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                        Client client = ((Recruit)setup.Attacker).Owner;
                                        client.Player.GetActiveRecruit().Exp = client.Player.GetActiveRecruit().GetNextLevel();
                                        PlayerLevelUp(setup.PacketStack, client);
                                    } else {
                                        ((MapNpc)setup.Attacker).Level++;
                                    }
                                }
                            }
                        }
                        break;
                    case 2: {
                            //Escape Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                //if (client.Player.PK == true) {
                                //    Messenger.PlayerMsg(client, "An outlaw cannot escape!", Text.BrightRed);
                                Escape(client);

                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " escaped from the dungeon!", Text.Yellow), setup.Attacker.X, setup.Attacker.Y, 10);
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("escape.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                                setup.AttackerMap.ActiveNpc[((MapNpc)setup.Attacker).MapSlot] = new MapNpc(setup.Attacker.MapID, ((MapNpc)setup.Attacker).MapSlot);
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, TcpPacket.CreatePacket("npcdead", ((MapNpc)setup.Attacker).MapSlot));
                            }
                        }
                        break;
                    case 3: {
                            //Adds a stat
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            int rand = ItemManager.Items[itemNum].Data2;
                            switch (rand) {
                                case 0: {
                                        setup.Attacker.MaxHPBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Maximum HP was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 1: {
                                        setup.Attacker.AtkBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Attack was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 2: {
                                        setup.Attacker.DefBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Defense was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 3: {
                                        setup.Attacker.SpclAtkBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Special Attack was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 4: {
                                        setup.Attacker.SpclDefBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Special Defense was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 5: {
                                        setup.Attacker.SpdBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Speed was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                            }

                            setup.Attacker.CalculateOriginalStats();
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                PacketBuilder.AppendStats(client, setup.PacketStack);
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);

                        }
                        break;
                    case 4: {
                            //Chamber Key
                            int x = setup.Attacker.X;
                            int y = setup.Attacker.Y;
                            MoveInDirection(setup.Attacker.Direction, 1, ref x, ref y);
                            if (x >= 0 && x <= setup.AttackerMap.MaxX && y >= 0 && y <= setup.AttackerMap.MaxY) {
                                Tile tile = setup.AttackerMap.Tile[x, y];
                                if (tile.Type == Enums.TileType.ScriptedSign && tile.Data1 == 10) {
                                    TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                    string[] start = tile.String1.Split(':');
                                    string[] end = tile.String2.Split(':');

                                    ClearChamber(setup.AttackerMap, x + start[0].ToInt(), y + start[1].ToInt(), x + end[0].ToInt(), y + end[1].ToInt(), setup.PacketStack);
                                }
                            }
                        }
                        break;
                    case 5: {
                            //fossil revival
                       if (Server.Globals.ServerTime == Enums.Time.Night) {
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {

                                Client client = ((Recruit)setup.Attacker).Owner;
                                IMap map = client.Player.Map;

                                if (map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Scripted && map.Tile[client.Player.X, client.Player.Y].Data1 == 71) {
                                    TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                    //Messenger.PlayerMsg(client, "And then " + Pokedex.GetPokemon(ItemManager.Items[itemNum].Data2).Name + " appears.", Text.Pink);
                                    map.SetTile(9, 0, 0, 1, 7);
                                    map.SetTile(9, 0, 0, 1, 8);
                                    setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(9, 0, map));
                                    map.SetTile(9, 1, 0, 1, 7);
                                    map.SetTile(9, 1, 0, 1, 8);
                                    setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(9, 1, map));
                                    map.SetTile(9, 2, 0, 1, 7);
                                    map.SetTile(9, 2, 0, 1, 8);
                                    setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(9, 2, map));
                                    map.SetAttribute(9, 3, Enums.TileType.Walkable, 0, 0, 0, "", "", "");
                                    setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(9, 3, map));

                                    Story story = new Story();
                                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                    StoryBuilder.AppendPlayMusicAction(segment, "PMD2) Growing Anxiety.ogg", true, true);
                                    StoryBuilder.AppendRunScriptAction(segment, 5, "magic654.wav", "", "", true);
                                            StoryBuilder.AppendSaySegment(segment, "The moonlight bathes the " + ItemManager.Items[itemNum].Name + " in its mysterious red glow...", -1, 0, 0);
                                            StoryBuilder.AppendSaySegment(segment, "The " + ItemManager.Items[itemNum].Name + " is glowing with an intense, ancient power...!", -1, 0, 0);
                                            StoryBuilder.AppendMapVisibilityAction(segment, false);
                                            StoryBuilder.AppendRunScriptAction(segment, 5, "magic685.wav", "", "", true);
                                            StoryBuilder.AppendSaySegment(segment, "!!!!!!!!!", -1, 0, 0);
                                            StoryBuilder.AppendRunScriptAction(segment, 5, "magic648.wav", "", "", true);
                                            StoryBuilder.AppendWarpAction(segment, client.Player.Map.MapID, 9, 12);
                                            StoryBuilder.AppendMapVisibilityAction(segment, true);
                                            StoryBuilder.AppendCreateFNPCAction(segment, "0", "s-2", 9, 3, ItemManager.Items[itemNum].Data2);
                                            StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Enums.Direction.Up);
                                            StoryBuilder.AppendSaySegment(segment, Pokedex.GetPokemon(ItemManager.Items[itemNum].Data2).Name + " was revived from the fossil!", -1, 0, 0);
                                            StoryBuilder.AppendPauseAction(segment, 200);
                                            StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Enums.Direction.Right);
                                            StoryBuilder.AppendPauseAction(segment, 200);
                                            StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Enums.Direction.Left);
                                            StoryBuilder.AppendPauseAction(segment, 200);
                                            StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Enums.Direction.Right);
                                            StoryBuilder.AppendPauseAction(segment, 200);
                                            StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Enums.Direction.Left);
                                            StoryBuilder.AppendPauseAction(segment, 200);
                                            StoryBuilder.AppendSaySegment(segment, "It's looking around desperately, as if confused...", -1, 0, 0);
                                            StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Enums.Direction.Down);
                                            StoryBuilder.AppendSaySegment(segment, "...It seems to take your presence as a threat!  It's going to attack!", -1, 0, 0);
                                            StoryBuilder.AppendDeleteFNPCAction(segment, "0");
                                            StoryBuilder.AppendPlayMusicAction(segment, "St2) Elite 4 Battle 2.ogg", true, true);
                                            StoryBuilder.AppendRunScriptAction(segment, 46, ItemManager.Items[itemNum].Data2.ToString(), "25", "0", false);

                                    segment.AppendToStory(story);
                                    StoryManager.PlayStory(client, story);

                                }
                            }
                          }
                        }
                        break;
                    case 6: {
                            //level down
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (!setup.Attacker.HasActiveItem(92) && setup.Attacker.Level > 1) {
                                int negative = ItemManager.Items[itemNum].Data2;
                                if (negative > setup.Attacker.Level - 1) negative = setup.Attacker.Level - 1;
                                setup.Attacker.Level -= negative;
                                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                    Client client = ((Recruit)setup.Attacker).Owner;
                                    client.Player.GetActiveRecruit().Exp = client.Player.GetActiveRecruit().GetNextLevel() - 1;
                                }
                                setup.Attacker.CalculateOriginalStats();
                                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                    Client client = ((Recruit)setup.Attacker).Owner;
                                    PacketBuilder.AppendStats(client, setup.PacketStack);
                                }
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " dropped to level " + setup.Attacker.Level + "!", Text.BrightRed));
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap,  PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke));
                            }
                        }
                        break;
                    case 7: {
                            //level 1
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (!setup.Attacker.HasActiveItem(92)) {
                                setup.Attacker.Level = 1;
                                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                    Client client = ((Recruit)setup.Attacker).Owner;
                                    client.Player.GetActiveRecruit().Exp = 0;
                                }
                                setup.Attacker.AtkBonus = 0;
                                setup.Attacker.DefBonus = 0;
                                setup.Attacker.SpdBonus = 0;
                                setup.Attacker.SpclAtkBonus = 0;
                                setup.Attacker.SpclDefBonus = 0;
                                setup.Attacker.CalculateOriginalStats();
                                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                    Client client = ((Recruit)setup.Attacker).Owner;
                                    PacketBuilder.AppendStats(client, setup.PacketStack);
                                }
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " dropped to level 1!", Text.Magenta));
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap,  PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke));
                            }
                        }
                        break;
                    case 8: {
                            //Adds Speed

                        }
                        break;
                    case 9: {
                            //adds a random stat
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            int rand = Server.Math.Rand(0, 6);
                            switch (rand) {
                                case 0: {
                                        setup.Attacker.MaxHPBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Maximum HP was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 1: {
                                        setup.Attacker.AtkBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Attack was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 2: {
                                        setup.Attacker.DefBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Defense was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 3: {
                                        setup.Attacker.SpclAtkBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Special Attack was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 4: {
                                        setup.Attacker.SpclDefBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Special Defense was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                                case 5: {
                                        setup.Attacker.SpdBonus += ItemManager.Items[itemNum].Data3;
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Speed was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    break;
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);

                        }
                        break;
                    case 10: {//Adds all stats
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);

                            setup.Attacker.MaxHPBonus += ItemManager.Items[itemNum].Data3;
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Maximum HP was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Attacker.AtkBonus += ItemManager.Items[itemNum].Data3;
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Attack was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Attacker.DefBonus += ItemManager.Items[itemNum].Data3;
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Defense was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Attacker.SpclAtkBonus += ItemManager.Items[itemNum].Data3;
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Special Attack was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Attacker.SpclDefBonus += ItemManager.Items[itemNum].Data3;
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Special Defense was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Attacker.SpdBonus += ItemManager.Items[itemNum].Data3;
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s Speed was boosted!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);

                        }
                        break;
                    case 11: {
                            //Full HP recovery
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            //if (GetBattleTagArg(setup.BattleTags, "Gluttony", 0) != null) {
                            //HealCharacter(setup.Attacker, setup.AttackerMap, ItemManager.Items[itemNum].Data2 + GetBattleTagArg(setup.BattleTags, "Gluttony", 0).ToInt(), setup.PacketStack);
                            //} else {
                            HealCharacter(setup.Attacker, setup.AttackerMap, setup.Attacker.MaxHP, setup.PacketStack);
                            //}
                            HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data3, setup.PacketStack);
                        }
                        break;
                    case 12: {
                            //Box
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                //TODO: check if the player has a key, and ask to open with the key
                                Messenger.PlaySoundToMap(client.Player.MapID, "magic669.wav");
                                Messenger.PlayerMsg(client, "The box is locked shut.  Perhaps there's someone who knows how to open it...", Text.Cyan);
                                /*
                                if (client.Player.Map.Moral == Enums.MapMoral.Safe || client.Player.Map.Moral == Enums.MapMoral.House) {
                                    Messenger.PlayerMsg(client, "You opened up the " + ItemManager.Items[itemNum].Name + "!", Text.Yellow);
                                    string[] itemSelection = client.Player.Inventory[invNum].Tag.Split(';');
                                    string[] chosenItem = itemSelection[Server.Math.Rand(0, itemSelection.Length)].Split(',');
                                    client.Player.TakeItemSlot(invNum, 1, true);
                                    if (chosenItem[0].IsNumeric()) {
                                        if (chosenItem.Length > 1 && chosenItem[1].IsNumeric()) {
                                            client.Player.GiveItem(chosenItem[0].ToInt(), chosenItem[1].ToInt());
                                            Messenger.PlayerMsg(client, "Inside was " + chosenItem[1] + " " + ItemManager.Items[chosenItem[0].ToInt()].Name + "!", Text.Yellow);
                                        } else {
                                            client.Player.GiveItem(chosenItem[0].ToInt(), 1);
                                            Messenger.PlayerMsg(client, "Inside was a " + ItemManager.Items[chosenItem[0].ToInt()].Name + "!", Text.Yellow);
                                        }
                                    } else {
                                        Messenger.PlayerMsg(client, "But there was nothing inside...", Text.Yellow);
                                    }
                                } else {
                                    Messenger.PlayerMsg(client, "This item cannot be opened in dungeons!", Text.BrightRed);
                                }
                                */
                            }
                        }
                        break;
                    case 13: {
                            //Unknown Effect Mushroom
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);

                            string[] effects = item.Tag.Split(';');
                            for (int i = 0; i < effects.Length; i++) {
                                //trigger each effect

                            }

                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 14: {
                            //herbal tea
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            HealCharacter(setup.Attacker, setup.AttackerMap, 100, setup.PacketStack);
                            HealCharacterPP(setup.Attacker, setup.AttackerMap, 10, setup.PacketStack);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "Yawn", 3, null, "", setup.PacketStack);

                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 15: {
                            //warp seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.AttackerMap.MapType == Enums.MapType.RDungeonMap) {
                                RandomWarp(setup.Attacker, setup.AttackerMap, true, setup.PacketStack);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 16: {
                            //Single Nonvolatile Status Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.StatusAilment == (Enums.StatusAilment)ItemManager.Items[itemNum].Data2) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, setup.PacketStack);
                            } else {
                                //setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                                AddExtraStatus(setup.Attacker, setup.AttackerMap, "Status Guard", 10, null, ItemManager.Items[itemNum].Data2.ToString(), setup.PacketStack);
                            }
                            HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data3, setup.PacketStack);
                        }
                        break;
                    case 17: {
                            //HP recovery
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            //if (GetBattleTagArg(setup.BattleTags, "Gluttony", 0) != null) {
                            //HealCharacter(setup.Attacker, setup.AttackerMap, ItemManager.Items[itemNum].Data2 + GetBattleTagArg(setup.BattleTags, "Gluttony", 0).ToInt(), setup.PacketStack);
                            //} else {
                            if (ItemManager.Items[itemNum].Data2 >= 0) {
                                HealCharacter(setup.Attacker, setup.AttackerMap, ItemManager.Items[itemNum].Data2, setup.PacketStack);
                            } else {
                                DamageCharacter(setup.Attacker, setup.AttackerMap, ItemManager.Items[itemNum].Data2, Enums.KillType.Other, setup.PacketStack, true);
                            }
                            //}
                            HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data3, setup.PacketStack);
                        }
                        break;
                    case 18: {
                            //PP recovery
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            HealCharacterPP(setup.Attacker, setup.AttackerMap, ItemManager.Items[itemNum].Data2, setup.PacketStack);

                            HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data3, setup.PacketStack);
                        }
                        break;
                    case 19: {
                            //Belly recovery
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {

                                if (((Recruit)setup.Attacker).Belly < ((Recruit)setup.Attacker).MaxBelly) {

                                    if (ItemManager.Items[itemNum].Data2 >= 1000 && ((Recruit)setup.Attacker).MaxBelly < 200) {
                                        ((Recruit)setup.Attacker).MaxBelly += (ItemManager.Items[itemNum].Data2 / 100);
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s belly size increased!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }

                                    HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data2, setup.PacketStack);

                                } else {
                                    ((Recruit)setup.Attacker).MaxBelly += ItemManager.Items[itemNum].Data3;
                                    setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s belly size increased!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                                    HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data3, setup.PacketStack);
                                }
                                if (((Recruit)setup.Attacker).MaxBelly > 200 && ((Recruit)setup.Attacker).MaxBelly < 200) {
                                    ((Recruit)setup.Attacker).MaxBelly = 200;
                                }
                                if (((Recruit)setup.Attacker).Belly > ((Recruit)setup.Attacker).MaxBelly) {
                                    ((Recruit)setup.Attacker).Belly = ((Recruit)setup.Attacker).MaxBelly;
                                }
                                PacketBuilder.AppendBelly(((Recruit)setup.Attacker).Owner, setup.PacketStack);
                            }
                        }
                        break;
                    case 20: {
                            //Multi-Belly recovery
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                                   	if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                                   		HealCharacterBelly(client.Player.Team[i], ItemManager.Items[itemNum].Data2, setup.PacketStack);
                                    }
                                }
                            }
                        }
                        break;
                    case 21: {
                            //sweet heart
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            int add = 5;
                            TargetCollection targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, setup.AttackerMap, setup.Attacker, setup.Attacker.X, setup.Attacker.Y, Enums.Direction.Up, false, true, false);
                            for (int i = 0; i < targets.Friends.Count; i++) {
                                int dx = setup.Attacker.X - targets[i].X;
                                int dy = setup.Attacker.Y - targets[i].Y;
                                if (dx < 2 && dy < 2) {
                                    add += 5;
                                } else if (dx < 8 && dy < 8) {
                                    add += 4;
                                } else if (dx < 16 && dy < 16) {
                                    add += 3;
                                } else {
                                    add += 2;
                                }
                            }
                            if (add > 5) {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("The feelings of nearby friends made it sweeter!", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                            HealCharacter(setup.Attacker, setup.AttackerMap, add*4, setup.PacketStack);
                            HealCharacterPP(setup.Attacker, setup.AttackerMap, add, setup.PacketStack);

                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 22: {
                            //casteliacone
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            //HealCharacter(setup.Attacker, setup.AttackerMap, setup.Attacker.MaxHP, setup.PacketStack);
                            HealCharacterPP(setup.Attacker, setup.AttackerMap, 100, setup.PacketStack);
                            SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, setup.PacketStack);
                            if (Server.Math.Rand(0, 3) == 0 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Freeze.ToString(), false, setup.PacketStack)) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Freeze, 0, setup.PacketStack);
                            }

                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 23: { // Pounce Orb
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                client.Player.TakeItemSlot(invNum, 1, true);
                                IMap map = client.Player.Map;
                                Messenger.MapMsg(map.MapID, client.Player.Name + " used a Pounce Orb!", Text.BrightCyan);
                                int npc = FindNearestNpc(client);
                                int playerX = client.Player.X;
                                int playerY = client.Player.Y;
                                if (IsPathClear(client, npc)) {
                                    MapNpc activeNpc = map.ActiveNpc[npc];
                                    if (playerX == activeNpc.X) {
                                        if (playerY > activeNpc.Y) {
                                            Messenger.PlayerWarp(client, map, playerX, activeNpc.Y + 1);
                                        } else {
                                            Messenger.PlayerWarp(client, map, playerX, activeNpc.Y - 1);
                                        }
                                    } else {
                                        if (playerX > activeNpc.X) {
                                            Messenger.PlayerWarp(client, map, activeNpc.X + 1, playerY);
                                        } else {
                                            Messenger.PlayerWarp(client, map, activeNpc.X - 1, playerY);
                                        }
                                    }
                                } else {
                                    int blockX = 0;
                                    int blockY = 0;
                                    FindNearestBlock(setup.AttackerMap, client.Player.Direction, ref blockX, ref blockY);
                                    Messenger.PlayerWarp(client, map, blockX, blockY);
                                }
                                Messenger.PlaySoundToMap(setup.AttackerMap.MapID, "magic50.wav");
                            }
                        }
                        break;
                    case 24: { // Blowback Orb
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                int npc = FindNearestNpc(client);
                                IMap map = client.Player.Map;
                                if (IsPathClear(client, npc)) {
                                    client.Player.TakeItem(181, 1);
                                    Messenger.MapMsg(map.MapID, "An enemy was blown back!", Text.BrightCyan);
                                    int x = 0;
                                    int y = 0;
                                    FindNearestBlock(setup.AttackerMap, client.Player.Direction, ref x, ref y);
                                    MapNpc activeNpc = map.ActiveNpc[npc];
                                    activeNpc.X = x;
                                    activeNpc.Y = y;
                                    int npc2 = FindNearestNpc(client);
                                    if (npc2 != npc) {
                                        MapNpc activeNpc2 = map.ActiveNpc[npc2];
                                        if (activeNpc.X == activeNpc2.X) {
                                            if (activeNpc.Y > activeNpc2.Y) {
                                                activeNpc.Y = activeNpc2.Y - 1;
                                            } else {
                                                activeNpc.Y = activeNpc2.Y + 1;
                                            }
                                        } else {
                                            if (activeNpc.X > activeNpc2.X) {
                                                activeNpc.X = activeNpc2.X - 1;
                                            } else {
                                                activeNpc.X = activeNpc2.X + 1;
                                            }
                                        }
                                        //BattleProcessor.PlayerAttackNpc(client, npc2, 15);
                                    }
                                    //BattleProcessor.PlayerAttackNpc(client, npc, 15);
                                    // SendMapNpc
                                } else {
                                    Messenger.PlayerMsg(client, "It had no effect!", Text.BrightRed);
                                }
                                Messenger.PlaySoundToMap(setup.AttackerMap.MapID, "magic50.wav");
                            }
                        }
                        break;

                    case 25: {//Two-Edge Orb
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                client.Player.TakeItemSlot(invNum, 1, true);
                                IMap map = client.Player.Map;
                                for (int j = 0; j <= 14; j++) {
                                    if (map.ActiveNpc[j].Num > 0) {
                                        if (setup.Attacker.Level >= map.ActiveNpc[j].Level) {
                                            map.ActiveNpc[j].HP = 1;
                                        }
                                        map.ActiveNpc[j].Target = client;
                                    }
                                }

                                Messenger.BattleMsg(client, "All weaker foes in the room are now close to fainting!", Text.BrightRed);
                                //DamagePlayer(client, (setup.Attacker.HP / 2), Enums.KillType.Npc);
                                Messenger.PlaySoundToMap(setup.AttackerMap.MapID, "magic54.wav");
                            }
                        }
                        break;

                    case 26: {//White Flute ~adjust for NPC levels (still unfinished)
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                Messenger.BattleMsg(client, "You used the White Flute!", Text.White);
                                //Messenger.SpellAnim(498, setup.AttackerMap, client.Player.X, client.Player.Y);
                                Messenger.PlaySoundToMap(setup.AttackerMap.MapID, "magic52.wav");
                                IMap map = client.Player.Map;
                                for (int j = 0; j <= 14; j++) {
                                    //if (CheckPlayerRange(index, j, 5, Enums.TargetType.Npc) == true && CheckTarget(index, j, Enums.TargetType.Npc) == true) {
                                    map.ActiveNpc[j].Target = client;
                                    //}
                                }
                                Messenger.BattleMsg(client, "Other Pokémon were lured.", Text.White);
                            }
                        }
                        break;

                    case 27: {//Black Flute
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                Messenger.BattleMsg(client, "You used the Black Flute!", Text.White);
                                //Messenger.SpellAnim(498, setup.AttackerMap, client.Player.X, client.Player.Y);
                                Messenger.PlaySoundToMap(setup.AttackerMap.MapID, "magic52.wav");
                                IMap map = client.Player.Map;
                                for (int j = 0; j <= 14; j++) {
                                    //if (CheckPlayerRange(index, j, 5, Enums.TargetType.Npc) == true && CheckTarget(index, j, Enums.TargetType.Npc) == true && ObjectFactory.GetMapNpc(setup.AttackerMap, j).Target == index) {
                                    map.ActiveNpc[j].Target = null;
                                    //}
                                }
                                Messenger.BattleMsg(client, "Other Pokémon were repelled.", Text.White);
                            }
                        }
                        break;
                    case 28: {//trawl orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("Magic322.wav"), setup.Attacker.X, setup.Attacker.Y, 50);
                            if (setup.AttackerMap.MapType == Enums.MapType.RDungeonMap) {

                                for (int i = 0; i < Server.Constants.MAX_MAP_ITEMS; i++) {
                                    if (setup.AttackerMap.ActiveItem[i].Num != 0 && !setup.AttackerMap.ActiveItem[i].Hidden
                                        && setup.AttackerMap.Tile[setup.AttackerMap.ActiveItem[i].X, setup.AttackerMap.ActiveItem[i].Y].Type != Enums.TileType.DropShop) {
                                        int x = Server.Math.Rand(setup.Attacker.X-1, setup.Attacker.X+2);
                                        int y = Server.Math.Rand(setup.Attacker.Y-1, setup.Attacker.Y+2);
                                        if (x < 0) x = 0;
                                        if (x >= setup.AttackerMap.MaxX) x = setup.AttackerMap.MaxX-1;
                                        if (y < 0) y = 0;
                                        if (y >= setup.AttackerMap.MaxY) y = setup.AttackerMap.MaxY-1;
                                        setup.AttackerMap.SpawnItemSlot(i, setup.AttackerMap.ActiveItem[i].Num, setup.AttackerMap.ActiveItem[i].Value,
                                        setup.AttackerMap.ActiveItem[i].Sticky, false, setup.AttackerMap.ActiveItem[i].Tag, x, y, null);
                                    }
                                }
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("Items were pulled close to "+setup.Attacker.Name+"!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("Items can only be pulled in Mystery Dungeons!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            }

                        }
                        break;
                    case 29: {
                            //Quick Seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            //if ((int)client.Player.SpeedLimit < 6) {
                            //client.Player.SpeedLimit++;
                            //Messenger.SendSpeedLimit(client);
                            //    if (setup.Attacker.VolatileStatus.GetStatus("MovementSpeed") != null) {
                            //        AddExtraStatus(setup.Attacker, setup.AttackerMap, "MovementSpeed", setup.Attacker.VolatileStatus.GetStatus("MovementSpeed").Counter + 1, null, setup.PacketStack);
                            //    } else {
                            //        AddExtraStatus(setup.Attacker, setup.AttackerMap, "MovementSpeed", 1, null, setup.PacketStack);
                            //    }
                            //} else {
                            //    setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " can't go any faster!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            //}
                            status = setup.Attacker.VolatileStatus.GetStatus("MovementSpeed");
                            if (status != null) {
                                AddExtraStatus(setup.Attacker, setup.AttackerMap, "MovementSpeed", status.Counter + 1, null, "", setup.PacketStack);
                            } else {
                                AddExtraStatus(setup.Attacker, setup.AttackerMap, "MovementSpeed", 1, null, "", setup.PacketStack);
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 30: {
                            //Violent Seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            //StrBuff(index, 2, 0);
                            //PPBuff(index, 2, 0);
                            // TODO: Violent Seed [Scripts]
                        }
                        break;
                    case 31: {
                            //Bad EGG
                        }
                        break;
                    case 32: {//seaside key
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {

                                Client client = ((Recruit)setup.Attacker).Owner;
                                IMap map = client.Player.Map;
                            if (map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.RDungeonGoal) {
                                map.Tile[client.Player.X, client.Player.Y].Mask2Set = 4;
                                map.Tile[client.Player.X, client.Player.Y].Mask2 = 2;
                                map.Tile[client.Player.X, client.Player.Y].Data1 = 1;
                                map.TempChange = true;
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(client.Player.X, client.Player.Y, map));
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("The passage to the next floor was opened!", Text.BrightGreen), client.Player.X, client.Player.Y, 50);
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic127.wav"), client.Player.X, client.Player.Y, 50);
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateBattleDivider(), client.Player.X, client.Player.Y, 50);
                                TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            }
                            }
                        }
                        break;
                    case 33: {//Teru-Sama
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                client.Player.TakeItemSlot(invNum, 1, true);
                                client.CloseConnection();
                            }
                        }
                        break;

                    case 34: {// Lottery Ticket
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                if (DateTime.Now.DayOfWeek == Lottery.LOTTERY_DAY) {
                                    IMap map = client.Player.Map;
                                    if (map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.ScriptedSign
                                        && map.Tile[client.Player.X, client.Player.Y].Data1 == 5) {
                                        // Do nothing...
                                    } else {
                                        Messenger.PlayerMsg(client, "Today is " + Lottery.LOTTERY_DAY.ToString() + "! Go to Felicity to see if you won!", Text.Grey);
                                    }
                                } else {
                                    Messenger.PlayerMsg(client, "Talk to Felicity on " + Lottery.LOTTERY_DAY.ToString() + " to see if you won!", Text.Grey);
                                }
                            }
                        }
                        break;

                    case 35: {
                            //Attack Items
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            //setup.SetupMove(MoveManager.Moves[ItemManager.Items[itemNum].Data2].MoveNum]);
                            //setup.Move.Name = setup.Attacker.Name + " used the " + ItemManager.Items[itemNum].Name + "!";
                            setup.moveSlot = -1;
                            setup.moveIndex = ItemManager.Items[itemNum].Data2;
                            BattleProcessor.HandleAttack(setup);
                            if (ItemManager.Items[itemNum].Data3 > 0) {
                                HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data3, setup.PacketStack);
                            }
                        }
                        break;
                    case 36: {
                            //Gummi
                            // TODO: Type of Gummi is based on data2
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            //if (NetScript.GetPlayerClass(index) == 2 || NetScript.GetPlayerClass(index) == 6 || NetScript.GetPlayerClass(index) == 10) {
                            //    NetScript.SetPlayerMP(index, NetScript.GetPlayerMP(index) + 500);
                            //    NetScript.SetPlayerHP(index, NetScript.GetPlayerHP(index) + 500);
                            //} else {
                            //    NetScript.SetPlayerMP(index, NetScript.GetPlayerMP(index) + 50);
                            //    NetScript.SetPlayerHP(index, NetScript.GetPlayerHP(index) + 50);
                            //}
                        }
                        break;
                    case 37: {//Tasty Honey
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " used the Tasty Honey!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            if (setup.AttackerMap.Moral != Enums.MapMoral.Safe && setup.AttackerMap.Moral != Enums.MapMoral.House) {
                                for (int i = 0; i <  Constants.MAX_MAP_NPCS / 4; i++) {
                                    setup.AttackerMap.SpawnNpc();
                                }
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("Pokémon were attracted to the scent!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("Pokémon can't be lured in this area!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                        }
                        break;
                    case 38: {
                            //Grimy Food
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            int rand = Server.Math.Rand(0, 1000);
                            //if (setup.AttackerMap.Name == "Spinda's Cafe") rand = 0;
                            if (rand > 750 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Burn.ToString(), false, setup.PacketStack)) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Burn, 0, setup.PacketStack);
                            } else if (rand > 500 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Paralyze.ToString(), false, setup.PacketStack)) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Paralyze, 0, setup.PacketStack);
                            } else if (rand > 250 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Poison.ToString(), false, setup.PacketStack)) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Poison, 1, setup.PacketStack);
                            } else if (rand > 0) {
                                ChangeAttackBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                                ChangeSpAtkBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                            } else {
                                rand = Server.Math.Rand(0, 1000);
                                //if (setup.AttackerMap.Name == "Spinda's Cafe") rand = 0;
                                if (rand > 0) {
                                ChangeAttackBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                                ChangeSpAtkBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                                } else {
                                    DamageCharacter(setup.Attacker, setup.AttackerMap, Int32.MaxValue, Enums.KillType.Other, setup.PacketStack, true);
                                }
                            }
                            HealCharacterBelly(setup.Attacker, 30, setup.PacketStack);
                        }
                        break;
                    case 39: {
                            //Grimy Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            int rand = Server.Math.Rand(0, 14);
                            switch (rand) {
                                case 0: {
                                        ChangeAttackBuff(setup.Attacker, setup.AttackerMap, -1, setup.PacketStack);
                                    }
                                    break;
                                case 1: {
                                        ChangeDefenseBuff(setup.Attacker, setup.AttackerMap, -1, setup.PacketStack);
                                    }
                                    break;
                                case 2: {
                                        ChangeSpAtkBuff(setup.Attacker, setup.AttackerMap, -1, setup.PacketStack);
                                    }
                                    break;
                                case 3: {
                                        ChangeSpDefBuff(setup.Attacker, setup.AttackerMap, -1, setup.PacketStack);
                                    }
                                    break;
                                case 4: {
                                        ChangeAccuracyBuff(setup.Attacker, setup.AttackerMap, -1, setup.PacketStack);
                                    }
                                    break;
                                case 5: {
                                        ChangeEvasionBuff(setup.Attacker, setup.AttackerMap, -1, setup.PacketStack);
                                    }
                                    break;
                                case 6: {
                                        ChangeSpeedBuff(setup.Attacker, setup.AttackerMap, -1, setup.PacketStack);
                                    }
                                    break;
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 40: {
                            //Attack Items Infinite Use

                            //setup.SetupMove(MoveManager.Moves[ItemManager.Items[itemNum].Data2].MoveNum]);
                            //setup.Move.Name = setup.Attacker.Name + " used the " + ItemManager.Items[itemNum].Name + "!";
                            setup.moveSlot = -1;
                            setup.moveIndex = ItemManager.Items[itemNum].Data2;
                            BattleProcessor.HandleAttack(setup);
                            HealCharacterBelly(setup.Attacker, ItemManager.Items[itemNum].Data3, setup.PacketStack);
                        }
                        break;
                    case 41: {//Musical Items
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                for (int i = client.Player.X - 3; i <= client.Player.X + 3; i++) {
                                    for (int j = client.Player.Y - 3; j <= client.Player.Y + 3; j++) {
                                        if (i < 0 || j < 0 || i > client.Player.Map.MaxX || j > client.Player.Map.MaxY) {

                                        } else {
                                            setup.PacketStack.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSpellAnim(498, i, j));
                                        }
                                    }
                                }

                                string musicName = "";

                                switch (ItemManager.Items[itemNum].Data2) {
                                    case 1: {
                                            musicName = "PMD2) Northern Desert.ogg";
                                        }
                                        break;
                                    case 2: {
                                            musicName = "PMD2) Dark Crater.ogg";
                                        }
                                        break;
                                    case 3: {
                                            musicName = "PMD2) Sky Peak Snowfield.ogg";
                                        }
                                        break;
                                    case 4: {
                                            musicName = "PMD2) Miracle Sea.ogg";
                                        }
                                        break;
                                    case 5: {
                                            musicName = "PMD2) Concealed Ruins.ogg";
                                        }
                                        break;
                                    case 6: {
                                            musicName = "PMD2) Sky Peak Forest.ogg";
                                        }
                                        break;
                                    case 7: {
                                            musicName = "PMD) Sky Tower.ogg";
                                        }
                                        break;
                                    case 8: {
                                            musicName = "PMD2) Star Cave.ogg";
                                        }
                                        break;
                                    default: {
                                            musicName = "RBY) Lavender Town.ogg";
                                        }
                                        break;

                                }
                                TargetCollection targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Room, 3, client.Player.Map, null, client.Player.X, client.Player.Y, Enums.Direction.Up, true, true, true);
                                for (int i = 0; i < targets.Count; i++) {
                                    if (targets[i].CharacterType == Enums.CharacterType.Recruit) {
                                        Messenger.PlayMusic(((Recruit)targets[i]).Owner, musicName);
                                    }
                                }
                            }
                        }
                        break;
                    case 42: {
                            //traps
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic105.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                            bool trapPlaced = false;
                            if (setup.AttackerMap.Moral == Enums.MapMoral.None || setup.AttackerMap.Moral == Enums.MapMoral.NoPenalty) {
                                if (setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y].Type == Enums.TileType.Scripted && GetTrapType(setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y].Data1) != null) {
                                    //remove preexisting trap
                                    RemoveTrap(setup.AttackerMap, setup.Attacker.X, setup.Attacker.Y, setup.PacketStack);
                                }

                                if (setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y].Type == Enums.TileType.Walkable) {
                                    //set the trap on a walkable tile
                                    Tile tile = setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y];
                                    tile.Type = Enums.TileType.Scripted;
                                    tile.Data1 = ItemManager.Items[itemNum].Data2;
                                    tile.Data2 = 0;
                                    tile.Data3 = 2;
                                    if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                        tile.String1 = ((Recruit)setup.Attacker).Owner.Player.CharID;
                                        tile.String2 = ((Recruit)setup.Attacker).Owner.Player.GuildName;
                                    } else {
                                        tile.String1 = "";
                                        tile.String2 = "";
                                    }
                                    tile.String2 = ItemManager.Items[itemNum].Data3.ToString();
                                    setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " placed a trap!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                                    trapPlaced = true;
                                }
                            }

                            if (!trapPlaced) {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("A trap can't be placed here!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                        }
                        break;
                    case 43: {//Tanren Key
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {

                                Client client = ((Recruit)setup.Attacker).Owner;
                                IMap map = client.Player.Map;
                                TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                /*
                                string param1 = map.Tile[client.Player.X, client.Player.Y].String1;
                                string param2 = map.Tile[client.Player.X, client.Player.Y].String2;
                                string param3 = map.Tile[client.Player.X, client.Player.Y].String3;
                                if (client.Player.PartyID == null) {
                                    TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                    client.Player.WarpToRDungeon(param1.ToInt()-1, ((RDungeonMap)client.Player.Map).RDungeonFloor + 1);

                                } else {
                                    bool warp = true;
                                    Party party = PartyManager.FindPlayerParty(client);
                                    IMap sourceMap = client.Player.Map;
                                    foreach (Client member in party.GetOnlineMemberClients()) {
                                        if (!member.Player.Dead && member.Player.MapID == client.Player.MapID && (member.Player.X != client.Player.X || member.Player.Y != client.Player.Y)) {
                                            warp = false;
                                        }
                                    }

                                    if (warp) {
                                        TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                        foreach (Client member in party.GetOnlineMemberClients()) {
                                            if (member.Player.Map != sourceMap) continue;
                                            member.Player.WarpToRDungeon(param1.ToInt()-1, ((RDungeonMap)member.Player.Map).RDungeonFloor + 1);

                                        }
                                    } else {
                                        setup.PacketStack.AddPacket(client, PacketBuilder.CreateChatMsg("All surviving players on the floor must be on the goal in order to continue.", Text.WhiteSmoke));
                                    }
                                }
                              */
                            if (map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Scripted && map.Tile[client.Player.X, client.Player.Y].Data1 == 68) {
                                map.Tile[client.Player.X, client.Player.Y].Mask2Set = 4;
                                map.Tile[client.Player.X, client.Player.Y].Mask2 = 2;
                                map.Tile[client.Player.X, client.Player.Y].Data1 = 69;
                                map.Tile[client.Player.X, client.Player.Y].String2 = "";
                                map.TempChange = true;
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(client.Player.X, client.Player.Y, map));
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("A secret passage was opened!", Text.BrightGreen), client.Player.X, client.Player.Y, 50);
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic127.wav"), client.Player.X, client.Player.Y, 50);
                                setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateBattleDivider(), client.Player.X, client.Player.Y, 50);
                                TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            }

                            }
                        }
                        break;
                    case 44: {
                            //Gracidea
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.Species == 492 && setup.Attacker.Form == 0) {
                                setup.Attacker.PermanentForm = 1;
                                setup.Attacker.Form = 1;
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("Magic838.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSpellAnim(502, setup.Attacker.X, setup.Attacker.Y));
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " changed forme!", Text.BrightGreen), setup.Attacker.X, setup.Attacker.Y, 10);
                                RefreshCharacterTraits(setup.Attacker, setup.AttackerMap, setup.PacketStack);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }

                        }
                        break;
                    case 45: {
                            //Ragecandybar
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            HealCharacterBelly(setup.Attacker, 30, setup.PacketStack);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSpellAnim(500, setup.Attacker.X, setup.Attacker.Y));
                            TargetCollection targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Room, 3, setup.AttackerMap, setup.Attacker, setup.Attacker.X, setup.Attacker.Y, Enums.Direction.Up, false, true, false);
                            if (targets.Friends.Count > 0) {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " shared some pieces with the others!", Text.Pink), setup.Attacker.X, setup.Attacker.Y, 10);
                            for (int i = 0; i < targets.Friends.Count; i++) {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSpellAnim(Server.Moves.MoveManager.Moves[500].TravelingAnim, setup.Attacker.X, setup.Attacker.Y, targets.Friends[i].X - setup.Attacker.X, targets.Friends[i].Y - setup.Attacker.Y, 0));
                                HealCharacterBelly(targets.Friends[i], 30, setup.PacketStack);
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSpellAnim(504, targets.Friends[i].X, targets.Friends[i].Y));
                            }
                            }

                        }
                        break;
                    case 46: {//scanner orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("Magic322.wav"), setup.Attacker.X, setup.Attacker.Y, 50);
                            for (int i = 0; i < Server.Constants.MAX_MAP_ITEMS; i++) {
                                if (setup.AttackerMap.ActiveItem[i].Num != 0 && setup.AttackerMap.ActiveItem[i].Hidden) {
                                    setup.AttackerMap.SpawnItemSlot(i, setup.AttackerMap.ActiveItem[i].Num, setup.AttackerMap.ActiveItem[i].Value,
                                    setup.AttackerMap.ActiveItem[i].Sticky, false, setup.AttackerMap.ActiveItem[i].Tag,
                                    setup.AttackerMap.ActiveItem[i].X, setup.AttackerMap.ActiveItem[i].Y, null);
                                }
                            }
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("All hidden items on the floor were revealed!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);

                        }
                        break;
                    case 47: {
                            //Lava Cookie
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            HealCharacter(setup.Attacker, setup.AttackerMap, setup.Attacker.MaxHP, setup.PacketStack);
                            if (setup.Attacker.StatusAilment != Enums.StatusAilment.OK) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, null);
                                //Messenger.BattleMsg(client, "You are no longer poisoned!", Text.White);
                            } else {

                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 48: {
                            //Energy Root
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            HealCharacter(setup.Attacker, setup.AttackerMap, setup.Attacker.MaxHP, setup.PacketStack);
                            HealCharacterPP(setup.Attacker, setup.AttackerMap, 100, setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 200, setup.PacketStack);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "Nausea", 0, null, "", setup.PacketStack);

                        }
                        break;
                    case 49: {
                            //Slowpoketail
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            HealCharacterBelly(setup.Attacker, 60, setup.PacketStack);
                            TargetCollection targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, setup.AttackerMap, setup.Attacker, setup.Attacker.X, setup.Attacker.Y, Enums.Direction.Up, true, false, false);

                            for (int i = 0; i < targets.Count; i++) {
                                if (targets[i].Species == 79 || targets[i].Species == 80 || targets[i].Species == 199) {
                                    AddExtraStatus(targets[i], setup.AttackerMap, "Grudge", 0, null, "", setup.PacketStack);
                                }
                            }

                        }
                        break;
                    case 53: {
                            //Wonder Gummi
                            // TODO: Wonder Gummi
                            ////if (NetScript.GetPlayerClass(index) == 2 || NetScript.GetPlayerClass(index) == 6 || NetScript.GetPlayerClass(index) == 10) {
                            //client.Player.TakeItem(520, 1);
                            //NetScript.SetPlayerMP(index, NetScript.GetPlayerMP(index) + 500);
                            //NetScript.SetPlayerHP(index, NetScript.GetPlayerHP(index) + 500);
                            ////}
                        }
                        break;
                    case 55: {
                            //Old Gateau
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.StatusAilment != Enums.StatusAilment.OK) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, null);
                                //Messenger.BattleMsg(client, "You are no longer poisoned!", Text.White);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                            HealCharacterBelly(setup.Attacker, 30, setup.PacketStack);
                        }
                        break;
                    case 56: {//for west wing
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                if (client.Player.Direction == Enums.Direction.Up && setup.AttackerMap.MapID == MapManager.GenerateMapID(743) && client.Player.X == 11) {
                                    Messenger.AskQuestion(client, "AbandonedMansion", "Will you use the West Wing Key to enter?", -1);
                                } else {
                                    StoryManager.PlayStory(client, 298);
                                }
                            }
                        }
                        break;
                    case 57: {//for east wing
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                if (client.Player.Direction == Enums.Direction.Up && setup.AttackerMap.MapID == MapManager.GenerateMapID(743) && client.Player.X == 21) {
                                    Messenger.AskQuestion(client, "AbandonedMansion", "Will you use the East Wing Key to enter?", -1);
                                } else {
                                    StoryManager.PlayStory(client, 298);
                                }
                            }
                        }
                        break;
                    case 58: {//for abandoned mansion
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                if (client.Player.Direction == Enums.Direction.Up && setup.AttackerMap.MapID == MapManager.GenerateMapID(743) && client.Player.X == 16) {
                                    Messenger.AskQuestion(client, "AbandonedMansion", "Will you use the Mansion Key to enter?", -1);
                                } else {
                                    StoryManager.PlayStory(client, 298);
                                }
                            }
                        }
                        break;
                    case 59: {//One-Room Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.AttackerMap.MapType == Enums.MapType.RDungeonMap) {
                                RDungeonMap map = (RDungeonMap)setup.AttackerMap;
                                int[,] intArray = new int[map.MaxX + 1, map.MaxY + 1];
                                for (int x = 0; x <= map.MaxX; x++) {
                                    for (int y = 0; y <= map.MaxY; y++) {
                                        if (x == 0 || y == 0 || x == map.MaxX || y == map.MaxY) {
                                            map.Tile[x, y].RDungeonMapValue = 1;
                                            RDungeonFloorGen.AmbiguateTile(map.Tile[x, y]);
                                        } else if (map.Tile[x, y].RDungeonMapValue == 4 || map.Tile[x, y].RDungeonMapValue == 5 || map.Tile[x, y].RDungeonMapValue >= 256 && map.Tile[x, y].RDungeonMapValue < 512) {
                                            map.Tile[x, y].RDungeonMapValue = 3;
                                            RDungeonFloorGen.AmbiguateTile(map.Tile[x, y]);
                                        }
                                        intArray[x, y] = map.Tile[x, y].RDungeonMapValue;
                                    }
                                }
                                DungeonArrayFloor.TextureDungeon(intArray);

                                for (int x = 0; x <= map.MaxX; x++) {
                                    for (int y = 0; y <= map.MaxY; y++) {
                                        map.Tile[x, y].RDungeonMapValue = intArray[x, y];
                                    }
                                }

                                RDungeonFloorGen.TextureDungeonMap(map);

                                for (int x = 0; x <= map.MaxX; x++) {
                                    for (int y = 0; y <= map.MaxY; y++) {
                                        setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(x, y, map));
                                    }
                                }
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("The walls crumbled, forming one big room!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic174.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }

                        }
                        break;
                    case 60: {//Drought Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.AttackerMap.MapType == Enums.MapType.RDungeonMap) {
                                RDungeonMap map = (RDungeonMap)setup.AttackerMap;
                                int[,] intArray = new int[map.MaxX + 1, map.MaxY + 1];
                                for (int x = 0; x <= map.MaxX; x++) {
                                    for (int y = 0; y <= map.MaxY; y++) {
                                        if (map.Tile[x, y].RDungeonMapValue >= 512 && map.Tile[x, y].RDungeonMapValue < 768) {
                                            map.Tile[x, y].RDungeonMapValue = 3;
                                            RDungeonFloorGen.AmbiguateTile(map.Tile[x, y]);
                                        }
                                        intArray[x, y] = map.Tile[x, y].RDungeonMapValue;
                                    }
                                }

                                DungeonArrayFloor.TextureDungeon(intArray);

                                for (int x = 0; x <= map.MaxX; x++) {
                                    for (int y = 0; y <= map.MaxY; y++) {
                                        map.Tile[x, y].RDungeonMapValue = intArray[x, y];
                                    }
                                }

                                RDungeonFloorGen.TextureDungeonMap(map);

                                for (int x = 0; x <= map.MaxX; x++) {
                                    for (int y = 0; y <= map.MaxY; y++) {
                                        setup.PacketStack.AddPacketToMap(map, PacketBuilder.CreateTilePacket(x, y, map));
                                    }
                                }
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("All liquids were drained from the floor!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic170.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }

                        }
                        break;
                    case 61: {
                            //heal seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.StatusAilment != Enums.StatusAilment.OK) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, setup.PacketStack);
                                //Messenger.BattleMsg(client, "You are no longer poisoned!", Text.White);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 69: {
                            //blinker seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "Blind", 20, null, "", setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 70: {//Weather Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y].Type == Enums.TileType.Arena || setup.AttackerMap.Moral == Enums.MapMoral.None || setup.AttackerMap.Moral == Enums.MapMoral.NoPenalty) {
                                if (Server.Math.Rand(0, 10) == 0) {
                                    SetMapWeather(setup.AttackerMap, (Enums.Weather)ItemManager.Items[itemNum].Data3, setup.PacketStack);
                                } else {
                                    SetMapWeather(setup.AttackerMap, (Enums.Weather)ItemManager.Items[itemNum].Data2, setup.PacketStack);
                                }
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("The weather can only change in dungeons and arenas!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                        }
                        break;
                    case 71: {//Recycle Orb
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                bool grimy = false;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num != 74 && client.Player.Inventory[i].Num != 75) {
                                    } else if (client.Player.Inventory[i].Tag.IsNumeric() && client.Player.Inventory[i].Tag.ToInt() > 0) {
                                        int grimyItem = client.Player.Inventory[i].Num;
                                        client.Player.Inventory[i].Num = client.Player.Inventory[i].Tag.ToInt();
                                        client.Player.Inventory[i].Tag = "";
                                    } else {
                                        grimy = true;
                                    }
                                    if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                        PacketBuilder.AppendInventory(((Recruit)setup.Attacker).Owner, setup.PacketStack);
                                    }
                                }
                                Messenger.PlayerMsg(client, "Grimy items in the bag have been restored!", Text.Cyan);
                                Messenger.PlayerMsg(client, "But some items were too grimy to recycle...", Text.Blue);
                            }
                        }
                        break;
                    case 72: {//heart slate
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                int slot = -1;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num == 171 && !client.Player.Inventory[i].Tag.Contains(item.Tag)) {
                                        slot = i;
                                        break;
                                    }
                                }
                                if (slot > -1) {
                                    client.Player.Inventory[slot].Tag += (item.Tag + ";");
                                    TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                    Messenger.PlayerMsg(client, "The item disappeared, and its symbol was imprinted into the Mystery Part!", Text.Cyan);
                                    Messenger.PlaySoundToMap(client.Player.MapID, "magic765.wav");
                                } else {
                                    Messenger.PlayerMsg(client, "But nothing happened...", Text.Blue);
                                }

                            }
                        }
                        break;
                    case 73: {//mystery part
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                string[] choicesNum = item.Tag.Split(';');
                                if (choicesNum.Length > 1 && IsHardModeEntrance(setup.AttackerMap)) {
                                    List<string> choices = new List<string>();
                                    bool tooMany = false;
                                    for (int i = 0; i < choicesNum.Length-1; i++) {
                                        if (choices.Count >= 5) {
                                        tooMany = true;
                                            break;
                                        }
                                        choices.Add("#" + choicesNum[i] + ": " + Pokedex.GetPokemon(choicesNum[i].ToInt()).Name);
                                    }
                                    if (tooMany) {
                                        choices.Add("Others");
                                    }
                                    choices.Add("Cancel");

                                    Messenger.AskQuestion(client, "SummonGuardian:0:" + item.Tag, "Which ally will you call forth?", -1, choices.ToArray());
                                } else {
                                    setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened...", Text.Blue), setup.Attacker.X, setup.Attacker.Y, 10);
                                }
                            }
                        }
                        break;
                    case 74: {//Luminous Orb
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic322.wav"), setup.Attacker.X, setup.Attacker.Y, 10);
                                if (setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y].Type == Enums.TileType.Arena || setup.AttackerMap.Moral == Enums.MapMoral.None || setup.AttackerMap.Moral == Enums.MapMoral.NoPenalty) {
                                    AddMapStatus(setup.AttackerMap, "Luminous", 0, "", -1, setup.PacketStack);
                                } else {
                                    setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("The map can only be lit up in dungeons and arenas!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                                }
                            }
                        }
                        break;
                    case 75: {
                            //Vanish seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "Invisible", 20, null, "", setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 76: {//Cleanse Orb
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                Client client = ((Recruit)setup.Attacker).Owner;
                                TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Sticky) {
                                        client.Player.SetItemSticky(i, false);
                                    }
                                }
                                Messenger.PlayerMsg(client, "All sticky items have been cleansed!", Text.Cyan);
                            }
                        }
                        break;
                    case 77: {
                            //Pinch Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            // if (setup.Attacker.HP <= setup.Attacker.MaxHP / 2) {
                            int raisedStat = ItemManager.Items[itemNum].Data2;
                            if (raisedStat == -1) {
                                raisedStat = Server.Math.Rand(0, 7);
                            }
                            switch (raisedStat) {
                                case 0: {
                                        ChangeAttackBuff(setup.Attacker, setup.AttackerMap, 20, setup.PacketStack);
                                    }
                                    break;
                                case 1: {
                                        ChangeDefenseBuff(setup.Attacker, setup.AttackerMap, 20, setup.PacketStack);
                                    }
                                    break;
                                case 2: {
                                        ChangeSpAtkBuff(setup.Attacker, setup.AttackerMap, 20, setup.PacketStack);
                                    }
                                    break;
                                case 3: {
                                        ChangeSpDefBuff(setup.Attacker, setup.AttackerMap, 20, setup.PacketStack);
                                    }
                                    break;
                                case 4: {
                                        ChangeSpeedBuff(setup.Attacker, setup.AttackerMap, 20, setup.PacketStack);
                                    }
                                    break;
                                case 5: {
                                        ChangeAccuracyBuff(setup.Attacker, setup.AttackerMap, 20, setup.PacketStack);
                                    }
                                    break;
                                case 6: {
                                        ChangeEvasionBuff(setup.Attacker, setup.AttackerMap, 20, setup.PacketStack);
                                    }
                                    break;
                            }
                            //} else {
                            //    setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            //}
                            //HealCharacter(setup.Attacker, setup.AttackerMap, setup.Attacker.MaxHP / 2, setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 78: {
                            //Persim Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);

                            if (setup.Attacker.VolatileStatus.GetStatus("Confusion") != null) {
                                RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Confusion", setup.PacketStack);
                            } else {
                                //setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                                AddExtraStatus(setup.Attacker, setup.AttackerMap, "Confusion Guard", 10, null, "", setup.PacketStack);
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 79: {
                            //Lum Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.Attacker.StatusAilment != Enums.StatusAilment.OK) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, setup.PacketStack);
                                //Messenger.BattleMsg(client, "You are no longer poisoned!", Text.White);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("But nothing happened.", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);
                            }
                            for (int i = setup.Attacker.VolatileStatus.Count - 1; i > -1; i--) {
                                if (IsStatusBad(setup.Attacker.VolatileStatus[i].Name)) {
                                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, setup.Attacker.VolatileStatus[i].Name, setup.PacketStack);
                                }
                            }
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 80: {
                            //Type-reduce Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "TypeReduce", ItemManager.Items[itemNum].Data2, null, "", setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 81: {
                            //Trap-See Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            for (int x = 0; x <= setup.AttackerMap.MaxX; x++) {
                                for (int y = 0; y <= setup.AttackerMap.MaxY; y++) {
                                    if (setup.AttackerMap.Tile[x, y].Type == Enums.TileType.Scripted && GetTrapType(setup.AttackerMap.Tile[x, y].Data1) != null && GetTrapType(setup.AttackerMap.Tile[x, y].Data1) != "SecretRoom") {
                                        RevealTrap(setup.AttackerMap, x, y, setup.PacketStack);
                                    }
                                }
                            }
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("All traps on the floor were exposed!", Text.Pink));
                        }
                        break;
                    case 82: {
                            //Trapbust Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            for (int x = 0; x <= setup.AttackerMap.MaxX; x++) {
                                for (int y = 0; y <= setup.AttackerMap.MaxY; y++) {
                                    if (setup.AttackerMap.Tile[x, y].Type == Enums.TileType.Scripted && GetTrapType(setup.AttackerMap.Tile[x, y].Data1) != null && GetTrapType(setup.AttackerMap.Tile[x, y].Data1) != "SecretRoom") {
                                        RemoveTrap(setup.AttackerMap, x, y, setup.PacketStack);
                                    }
                                }
                            }
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("All traps on the floor were destroyed!", Text.Pink));
                        }
                        break;
                    case 83: {//White Herb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            RemoveBuffs(setup.Attacker);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s stats were returned to normal!", Text.WhiteSmoke), setup.Attacker.X, setup.Attacker.Y, 10);

                            HealCharacterBelly(setup.Attacker, 3, setup.PacketStack);
                        }
                        break;
                    case 84: {//Evasion Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            ChangeEvasionBuff(setup.Attacker, setup.AttackerMap, 2, setup.PacketStack);

                        }
                        break;
                    case 85: {
                            //Slip Seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "Slip", 0, null, "", setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 86: {
                            //Mobile Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "SuperMobile", 0, null, "", setup.PacketStack);
                        }
                        break;
                    case 87: {//Power Herb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "SuperCharge", 0, null, "", setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 3, setup.PacketStack);
                        }
                        break;
                    case 88: {
                            //Type-boost gem
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "TypeBoost", ItemManager.Items[itemNum].Data2, null, "", setup.PacketStack);
                        }
                        break;
                    case 89: {//Mental Herb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Attract", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Encore", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Torment", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Taunt", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Disable", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "MoveSeal:0", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "MoveSeal:1", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "MoveSeal:2", setup.PacketStack);
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "MoveSeal:3", setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 3, setup.PacketStack);
                        }
                        break;
                    case 90: {//revives and max revives
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                ActivateRevivalItem(((Recruit)setup.Attacker).Owner, itemNum);
                            }
                        }
                        break;
                    case 91: {//Pathfinder Orb
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            Client client = ((Recruit)setup.Attacker).Owner;
                            if (setup.AttackerMap.Name != "Pitch-Black Abyss") {
                                Messenger.PlayerMsg(client, "The orb fills with a brilliant light, then fades out.", Text.Cyan);
                            } else {
                                int left, right, up, down;
                                string dir = "";
                                int x = -1;
                                int y = -1;

                                for (int i = 0; i < exPlayer.Get(client).DungeonMaxX; i++) {
                                    for (int j = 0; j < exPlayer.Get(client).DungeonMaxY; j++) {
                                        if (exPlayer.Get(client).DungeonMap[i,j] == PitchBlackAbyss.Room.End) {
                                            x = i;
                                            y = j;
                                        }
                                    }
                                }

                                if (exPlayer.Get(client).DungeonX >= x) {
                                    left = exPlayer.Get(client).DungeonX - x;
                                    right = exPlayer.Get(client).DungeonMaxX - left;
                                } else {
                                    right = x - exPlayer.Get(client).DungeonX;
                                    left = exPlayer.Get(client).DungeonMaxX - right;
                                }
                                if (exPlayer.Get(client).DungeonY >= y) {
                                    up = exPlayer.Get(client).DungeonY - y;
                                    down = exPlayer.Get(client).DungeonMaxY - up;
                                } else {
                                    down = y - exPlayer.Get(client).DungeonY;
                                    up = exPlayer.Get(client).DungeonMaxY - down;
                                }
                                    if (left == 0) {
                                    if (up < down) dir = "North";
                                    else dir = "South";
                                } else if (up == 0) {
                                    if (left < right) dir = "West";
                                    else dir = "East";
                                } else {
                                    //composite cases
                                    if (up < down) dir = "North";
                                    else dir = "South";
                                    if (left < right) dir = dir + "-West";
                                    else dir = dir + "-East";
                                }
                                Messenger.PlayerMsg(client, "The exit is to the " + dir + ".", Text.Cyan);
                            }
                        }
                        break;
                    case 92: { //sleep seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Sleep, Server.Math.Rand(2, 4), setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 93: { //dark liquid
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            HealCharacter(setup.Attacker, setup.AttackerMap, setup.Attacker.MaxHP, setup.PacketStack);
                            HealCharacterPP(setup.Attacker, setup.AttackerMap, 100, setup.PacketStack);
                            HealCharacterBelly(setup.Attacker, 200, setup.PacketStack);
                            //grimy food effect
                            int rand = Server.Math.Rand(0, 1000);
                            if (rand > 750 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Burn.ToString(), false, setup.PacketStack)) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Burn, 0, setup.PacketStack);
                            } else if (rand > 500 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Paralyze.ToString(), false, setup.PacketStack)) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Paralyze, 0, setup.PacketStack);
                            } else if (rand > 250 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Poison.ToString(), false, setup.PacketStack)) {
                                SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.Poison, 1, setup.PacketStack);
                            } else if (rand > 0) {
                                ChangeAttackBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                                ChangeSpAtkBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                            } else {
                                rand = Server.Math.Rand(0, 1000);
                                if (rand > 0) {
                                ChangeAttackBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                                ChangeSpAtkBuff(setup.Attacker, setup.AttackerMap, -3, setup.PacketStack);
                                } else {
                                    DamageCharacter(setup.Attacker, setup.AttackerMap, Int32.MaxValue, Enums.KillType.Other, setup.PacketStack, true);
                                }
                            }
                        }
                        break;
                    case 94: {
                            //jaboca/rowap Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            // if (setup.Attacker.HP <= setup.Attacker.MaxHP / 2) {

                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "AttackReturn", ItemManager.Items[itemNum].Data2, null, "", setup.PacketStack);

                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 95: {
                            //lansat Berry
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            // if (setup.Attacker.HP <= setup.Attacker.MaxHP / 2) {

                            AddExtraStatus(setup.Attacker, setup.AttackerMap, "FocusEnergy", 8, null, "", setup.PacketStack);

                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;
                    case 96: {
                            //pure seed
                            TakeItemSlotFromCharacter(setup.Attacker, invNum, 1);
                            if (setup.AttackerMap.MapType == Enums.MapType.RDungeonMap) {
                                WarpToStairs(setup.Attacker, setup.AttackerMap, setup.PacketStack, 5);
                            } else {
                                setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg("Warping works only Mystery Dungeons!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            }

                            HealCharacterBelly(setup.Attacker, 5, setup.PacketStack);
                        }
                        break;

                }
                //if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                    //Client client = ((Recruit)setup.Attacker).Owner;
                    //Logger.AppendToLog("/Player Event Logs/" + client.Player.Name + ".txt", "Used scripted item: " + ItemManager.Items[itemNum].Name, true);
                //}

            } catch (Exception ex) {
                Messenger.AdminMsg("Error: ScriptedItem " + item.Num + "-" + invNum, Text.Black);

                Messenger.AdminMsg(ex.ToString(), Text.Black);
            }
        }
Beispiel #10
0
        public static Story CreatePreDungeonStory(Client client, string param1, string param2, string param3, bool random)
        {
            Story story = new Story();

            StorySegment segment = new StorySegment();
            segment.Action = Enums.StoryAction.PlayerPadlock;
            segment.AddParameter("MovementState", "Lock");
            story.Segments.Add(segment);

            if (param3 == "") {
                //continuing a dungeon

                segment = new StorySegment();
                segment.Action = Enums.StoryAction.AskQuestion;
                segment.AddParameter("Question", "Will you go on?");
                segment.AddParameter("SegmentOnYes", (story.Segments.Count + 2).ToString());
                segment.AddParameter("SegmentOnNo", (story.Segments.Count + 3).ToString());
                segment.AddParameter("Mugshot", "-1");
                story.Segments.Add(segment);
            } else {

                string dungeonName = "";
                string reqString = "";
                string restrictionString = "";

                if (param3.IsNumeric()) {
                    //official dungeon

                    dungeonName = DungeonManager.Dungeons[param3.ToInt() - 1].Name;

                    if (DungeonManager.Dungeons[param3.ToInt() - 1].ScriptList.ContainsKey(1)) {
                        reqString = DungeonManager.Dungeons[param3.ToInt() - 1].ScriptList[1];
                    }

                    if (DungeonManager.Dungeons[param3.ToInt() - 1].ScriptList.ContainsKey(2)) {
                        restrictionString = DungeonManager.Dungeons[param3.ToInt() - 1].ScriptList[2];
                    }
                } else {
                    //unofficial dungeon

                    dungeonName = param3.Split(':')[0];
                    reqString = param3.Split(':')[1];
                    restrictionString = param3.Split(':')[2];
                }

                if (CheckDungeonRequirements(client, reqString.Split(';'))) {

                    if (restrictionString != "") {

                        AppendEntranceWarning(story, dungeonName, restrictionString.Split(';'));

                        segment = new StorySegment();
                        segment.Action = Enums.StoryAction.AskQuestion;
                        segment.AddParameter("Question", "Will you enter " + dungeonName + "?");
                        segment.AddParameter("SegmentOnYes", "3");
                        segment.AddParameter("SegmentOnNo", (story.Segments.Count + 4).ToString());
                        segment.AddParameter("Mugshot", "-1");
                        story.Segments.Insert(1, segment);

                        segment = new StorySegment();
                        segment.Action = Enums.StoryAction.AskQuestion;
                        segment.AddParameter("Question", "Is that OK?");
                        segment.AddParameter("SegmentOnYes", (story.Segments.Count + 2).ToString());
                        segment.AddParameter("SegmentOnNo", (story.Segments.Count + 3).ToString());
                        segment.AddParameter("Mugshot", "-1");
                        story.Segments.Add(segment);

                    } else {

                        segment = new StorySegment();
                        segment.Action = Enums.StoryAction.AskQuestion;
                        segment.AddParameter("Question", "Will you enter " + dungeonName + "?");
                        segment.AddParameter("SegmentOnYes", (story.Segments.Count + 2).ToString());
                        segment.AddParameter("SegmentOnNo", (story.Segments.Count + 3).ToString());
                        segment.AddParameter("Mugshot", "-1");
                        story.Segments.Insert(1, segment);

                    }

                } else {

                    AppendEntranceReqs(story, dungeonName, reqString.Split(';'));

                    segment = new StorySegment();
                    segment.Action = Enums.StoryAction.GoToSegment;
                    segment.AddParameter("Segment", (story.Segments.Count + 3).ToString());

                    story.Segments.Add(segment);

                    segment = new StorySegment();
                    segment.Action = Enums.StoryAction.AskQuestion;
                    segment.AddParameter("Question", "Will you enter " + dungeonName + "?");
                    segment.AddParameter("SegmentOnYes", "3");
                    segment.AddParameter("SegmentOnNo", (story.Segments.Count + 3).ToString());
                    segment.AddParameter("Mugshot", "-1");
                    story.Segments.Insert(1, segment);

                }

            }

            segment = new StorySegment();
            segment.Action = Enums.StoryAction.RunScript;
            if (random) {
                segment.AddParameter("ScriptIndex", "42");
            } else {
                segment.AddParameter("ScriptIndex", "52");
            }
            segment.AddParameter("ScriptParam1", param1);
            segment.AddParameter("ScriptParam2", param2);
            segment.AddParameter("ScriptParam3", param3);
            segment.AddParameter("Pause", "1");
            story.Segments.Add(segment);

            segment = new StorySegment();
            segment.Action = Enums.StoryAction.PlayerPadlock;
            segment.AddParameter("MovementState", "Unlock");
            story.Segments.Add(segment);

            foreach (StorySegment segments in story.Segments) {
                //Messenger.AdminMsg(segments.Action.ToString(), Text.Black);
            }

            return story;
        }
Beispiel #11
0
        public static void Commands(Client client, Command command)
        {
            try
            {
                string joinedArgs = JoinArgs(command.CommandArgs);
                PacketHitList hitlist = null;
                PacketHitList.MethodStart(ref hitlist);

                switch (command[0])
                {
                    case "/savelogs":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Logger.SaveLogs();
                                Messenger.PlayerMsg(client, "Logs have been saved.", Text.BrightGreen);
                            }
                        }
                        break;
                    case "/textstory":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Story story = new Story();

                                StoryBuilderSegment segment = new StoryBuilderSegment();

                                StoryBuilder.AppendSaySegment(segment, joinedArgs, 25, 0, 0);

                                segment.AppendToStory(story);

                                foreach (Client i in client.Player.Map.GetClients())
                                {
                                    StoryManager.PlayStory(i, story);
                                }
                            }
                        }
                        break;
                    case "/spawnminions":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                for (int i = 0; i < joinedArgs.ToInt(); i++)
                                {
                                    MapNpcPreset npc = new MapNpcPreset();
                                    npc.SpawnX = 22; //-1;
                                    npc.SpawnY = 32; //-1;
                                    npc.NpcNum = 1368;
                                    npc.MinLevel = 90;
                                    npc.MaxLevel = 100;
                                    client.Player.Map.SpawnNpc(npc);
                                }
                            }
                        }
                        break;
                    case "/serverstatus":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Server.Globals.ServerStatus = joinedArgs;
                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Server Status] " + client.Player.Name + " changed the server status to: '" + joinedArgs + "'");
                            }
                        }
                        break;
                    case "/togglequiz":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                InQuiz = !InQuiz;
                                QuestionReady = false;
                                Messenger.AdminMsg("[Staff] In Quiz: " + InQuiz.ToString(), Text.BrightBlue);
                            }
                        }
                        break;
                    case "/questionready":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                QuestionReady = true;
                                Messenger.AdminMsg("[Staff] Question Ready: " + QuestionReady.ToString(), Text.BrightGreen);
                                for (int a = 8; a >= 0; a--)
                                {
                                    Messenger.MapMsg(client.Player.MapID, "You can answer in: " + a, Text.BrightGreen);
                                    System.Threading.Thread.Sleep(1000);
                                    CanAnswer = false;
                                }

                                Messenger.MapMsg(client.Player.MapID, "You can now buzz in!", Text.BrightGreen);
                                CanAnswer = true;
                            }
                        }
                        break;
                    case "/yatterman":
                        {
                            if (client.Player.CharID.Substring(1).ToInt() % 2 == 0)
                            {
                                Messenger.PlayerMsg(client, "All of the PINK", System.Drawing.Color.LimeGreen);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "Slightly less PINK", Text.White);
                            }
                        }
                        break;
                    case "/glomp":
                        {
                            if (client.Player.Muted == false)
                            {
                                if (client.Player.CharID.Substring(1).ToInt() % 2 == 0)
                                {
                                    Messenger.MapMsg(client.Player.MapID, "Plusle Power! " + client.Player.Name + " used Glomp!", Text.Red);
                                }
                                else
                                {
                                    Messenger.MapMsg(client.Player.MapID, "Minun Power! " + client.Player.Name + " used Glomp!", Text.Cyan);
                                }

                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                            }

                        }
                        break;

                    case "/setquizanswer":
                        {
                            if (InQuiz)
                            {
                                if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                                {
                                    QuizAnswer = joinedArgs.ToLower();
                                    Messenger.AdminMsg("[Staff] Quiz answer set to: " + QuizAnswer, Text.BrightBlue);
                                }
                            }

                        }
                        break;
                    case "/buzz":
                        {
                            if (InQuiz && QuestionReady && CanAnswer)
                            {
                                //QuestionReady = false;
                                foreach (Client i in client.Player.Map.GetClients())
                                {
                                    if (i.IsPlaying())
                                    {

                                        Messenger.BattleMsg(i, client.Player.Name + " has answered with: " + joinedArgs, Text.BrightGreen);

                                        /* Story story = new Story();

                                         StoryBuilderSegment segment = new StoryBuilderSegment();

                                         StoryBuilder.AppendSaySegment(segment, client.Player.Name + " has buzzed in! " + client.Player.Name + "'s answer is...", -1, 0, 0);
                                         StoryBuilder.AppendSaySegment(segment, joinedArgs, -1, 0, 0);

                                         segment.AppendToStory(story);

                                         StoryManager.PlayStory(i, story);*/
                                    }

                                }
                                if (CanAnswer && joinedArgs.ToLower() == QuizAnswer)
                                {
                                    foreach (Client i in client.Player.Map.GetClients())
                                    {
                                        Messenger.PlayerMsg(i, client.Player.Name + " has answered correctly! The answer was: " + QuizAnswer, Text.Yellow);

                                    }
                                    QuestionReady = false;
                                    QuizAnswer = "";
                                }
                            }
                        }
                        break;
                    /*case "/plaza": {
                            //if (Ranks.IsAllowed(client, Server.Enums.Rank.Moniter)) {
                            IMap map = client.Player.Map;
                            //if (map.MapType == Enums.MapType.Standard && map.Name.StartsWith("Exbel")) {
                            //	exPlayer.Get(client).PlazaEntranceMap = client.Player.MapID;
                            //	exPlayer.Get(client).PlazaEntranceX = client.Player.X;
                            //	exPlayer.Get(client).PlazaEntranceY = client.Player.Y;

                            //	Messenger.PlayerWarp(client, 1777, 16, 20);
                            //	Messenger.PlayerMsg(client, "Welcome to the plaza!", Text.BrightGreen);
                            //} else {
                                Messenger.PlayerMsg(client, "You cannot enter the plaza from here!", Text.BrightRed);
                            //}
                        }
                        break;*/
                    //case "/leaveplaza": {
                    //        IMap map = client.Player.Map;
                    //        if (map.Name == "Delite Plaza") {
                    //            if (!string.IsNullOrEmpty(exPlayer.Get(client).PlazaEntranceMap)) {
                    //                Messenger.PlayerWarp(client, exPlayer.Get(client).PlazaEntranceMap, exPlayer.Get(client).PlazaEntranceX, exPlayer.Get(client).PlazaEntranceY);
                    //            }
                    //        }
                    //    }
                    //    break;
                    case "/endgame":
                        {
                            if (exPlayer.Get(client).SnowballGameInstance.GameLeader == client)
                            {
                                exPlayer.Get(client).SnowballGameInstance.EndGame();
                                Messenger.PlayerMsg(client, "You have ended the game.", Text.Yellow);
                            }
                        }
                        break;
                    case "/snowballplayers":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (Main.ActiveSnowballGames.Count > 0)
                                {
                                    Messenger.PlayerMsg(client, "Blue Team:", Text.Yellow);
                                    foreach (Client teamClient in Main.ActiveSnowballGames.Values[0].BlueTeam)
                                    {
                                        Messenger.PlayerMsg(client, teamClient.Player.Name, Text.Yellow);
                                    }
                                    Messenger.PlayerMsg(client, "Green Team:", Text.Yellow);
                                    foreach (Client teamClient in Main.ActiveSnowballGames.Values[0].GreenTeam)
                                    {
                                        Messenger.PlayerMsg(client, teamClient.Player.Name, Text.Yellow);
                                    }
                                }
                            }
                        }
                        break;
                    case "/gmmode":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Developer))
                            {
                                Server.Globals.GMOnly = !Server.Globals.GMOnly;
                                Messenger.PlayerMsg(client, "GM Only Mode Active: " + Server.Globals.GMOnly, Text.Yellow);
                            }
                        }
                        break;
                    case "/copymap":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                IMap baseMap = MapManager.RetrieveMap(command[1]);
                                IMap destinationMap = MapManager.RetrieveMap(command[2], true);
                                MapCloner.CloneMapTileProperties(baseMap, destinationMap);
                                MapCloner.CloneMapTiles(baseMap, destinationMap);
                                destinationMap.Revision++;
                                destinationMap.Save();
                                Messenger.PlayerWarp(client, destinationMap, 25, 25);
                            }
                        }
                        break;
                    case "/packetcaching":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Server.Globals.PacketCaching = !Server.Globals.PacketCaching;
                                Messenger.PlayerMsg(client, "Packet caching is: " + (Server.Globals.PacketCaching ? "on!" : "off!"), Text.BrightGreen);
                            }
                        }
                        break;
                    case "/foolsstory":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    //if (i != client) {
                                    StoryManager.PlayStory(i, 369 - 1);
                                    //}
                                }
                            }
                        }
                        break;
                    case "/foolsmode":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Server.Globals.FoolsMode = !Server.Globals.FoolsMode;
                                Messenger.SendDataToAll(TcpPacket.CreatePacket("foolsmode", Server.Globals.FoolsMode.ToIntString()));
                                Messenger.PlayerMsg(client, "April fool's mode is: " + (Server.Globals.FoolsMode ? "on!" : "off!"), Text.BrightGreen);
                            }
                        }
                        break;
                    case "/lokmovementall":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.AdminMsg("[Staff] Movement locked...", Text.BrightBlue);
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying() && Ranks.IsDisallowed(i, Enums.Rank.Moniter))
                                    {
                                        i.Player.MovementLocked = true;

                                        Messenger.PlayerMsg(i, "Movement has been locked, temporarily", Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    case "/unlokmovementall":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.AdminMsg("[Staff] Movement unlocked...", Text.BrightBlue);
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying())
                                    {
                                        i.Player.MovementLocked = false;

                                        Messenger.PlayerMsg(i, "Movement has been unlocked [Debugging]", Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    case "/lokmovementmap":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.AdminMsg("[Staff] Movement locked...", Text.BrightBlue);
                                foreach (Client i in client.Player.Map.GetClients())
                                {
                                    if (i.IsPlaying() && Ranks.IsDisallowed(i, Enums.Rank.Moniter))
                                    {
                                        i.Player.MovementLocked = true;

                                        Messenger.PlayerMsg(i, "You find yourself stuck to the floor!", Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    case "/unlokmovementmap":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.AdminMsg("[Staff] Movement unlocked...", Text.BrightBlue);
                                foreach (Client i in client.Player.Map.GetClients())
                                {
                                    if (i.IsPlaying())
                                    {
                                        i.Player.MovementLocked = false;

                                        Messenger.PlayerMsg(i, "You can move again!", Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    case "/currentsection":
                        {
                            if (exPlayer.Get(client).StoryEnabled)
                            {
                                if (command.CommandArgs.Count == 2)
                                {
                                    client.Player.StoryHelper.SaveSetting("[MainStory]-CurrentSection", joinedArgs.ToInt().ToString());
                                }
                                Messenger.PlayerMsg(client, "Current section: " + client.Player.StoryHelper.ReadSetting("[MainStory]-CurrentSection").ToInt().ToString(), Text.BrightGreen);
                            }
                        }
                        break;
                    case "/resetstory":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                StoryHelper.ResetStory(client);
                            }

                        }
                        break;
                    case "/storymode":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                exPlayer.Get(client).StoryEnabled = !exPlayer.Get(client).StoryEnabled;
                                Messenger.PlayerMsg(client, "Story mode is now " + (exPlayer.Get(client).StoryEnabled ? "on!" : "off!"), Text.BrightGreen);
                            }
                        }
                        break;

                    case "/staffauction":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                if (Auction.StaffAuction == false)
                                {
                                    Auction.StaffAuction = true;
                                    Messenger.AdminMsg("[Staff] Staff-only auction mode is now active.", Text.BrightBlue);
                                }
                                else if (Auction.StaffAuction == true)
                                {
                                    Auction.StaffAuction = false;
                                    Messenger.AdminMsg("[Staff] Staff-only auction mode is now disabled.", Text.BrightBlue);
                                }
                            }
                        }

                        break;
                    case "/itemowners":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                IMap map = client.Player.Map;

                                for (int i = 0; i < map.ActiveItem.Length; i++)
                                {
                                    if ((map.ActiveItem[i].Num > 0))
                                    {
                                        Messenger.PlayerMsg(client, i + ". \'" + map.ActiveItem[i].TimeDropped.Tick + "\'", Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    //case "/dungeonopen": {
                    //        Messenger.PlayerMsg(client, "Dungeon Unlocked: " + DungeonRules.IsDungeonUnlocked(client, joinedArgs.ToInt()), Text.BrightGreen);
                    //    }
                    //    break;
                    case "/givejob":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                //if (!client.Player.JobList.HasCompletedMission("0|-1|1|1|7|0|0|1|1|1|-1|1|0|3|0|0|-1|-1|-1|-1|0|-1|-1|-1|")) {
                                //client.Player.JobList.AddJob("0|-1|0|0|7|0|0|3|1|9|-1|46|0|3|0|0|-1|-1|-1|-1|0|-1|-1|-1|");

                                Messenger.PlayerMsg(client, "Job added!", Text.BrightGreen);
                                Messenger.SendJobList(client);
                            }
                        }
                        break;
                    case "/dungeonnpcs":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                IMap map = client.Player.Map;

                                for (int i = 0; i < map.Npc.Count; i++)
                                {
                                    if ((map.Npc[i].NpcNum > 0))
                                    {
                                        Messenger.PlayerMsg(client, map.Npc[i].NpcNum.ToString(), Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    case "/rdstartcheck":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                for (int i = 0; i < 10; i++)
                                {
                                    RDungeonMap map = RDungeonFloorGen.GenerateFloor(client, 54, 49, RDungeonManager.RDungeons[54].Floors[49].Options);
                                    Messenger.PlayerMsg(client, i.ToString(), Text.Black);
                                }
                            }
                        }
                        break;
                    case "/activemaps":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                IMap[] activeMaps = MapManager.ToArray();
                                Messenger.PlayerMsg(client, "Active Maps: " + activeMaps.Length.ToString(), Text.BrightGreen);
                                foreach (IMap map in activeMaps)
                                {
                                    Messenger.PlayerMsg(client, map.Name, Text.Yellow);
                                    int total = 0;
                                    foreach (MapPlayer playerOnMap in map.PlayersOnMap.GetPlayers())
                                    {
                                        //Messenger.PlayerMsg(client, "-" + playerOnMap, Text.Yellow);
                                        total++;
                                    }
                                    Messenger.PlayerMsg(client, "Total in map: " + total, Text.Red);
                                }
                            }
                        }
                        break;
                    case "/daynight":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Server.Events.World.TimedEventManager.TimedEvents["DayCycle"].OnTimeElapsed(Server.Core.GetTickCount());
                                Messenger.PlayerMsg(client, Server.Globals.ServerTime.ToString(), Text.BrightGreen);
                                //}
                            }
                        }
                        break;
                    case "/currenttime":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                TimeSpan time = new TimeSpan(0, 0, 0, 0, client.Player.MissionBoard.LastGenTime);
                                Messenger.PlayerMsg(client, time.TotalSeconds.ToString(), Text.BrightGreen);
                                time = new TimeSpan(0, 0, 0, 0, Server.Core.GetTickCount().Tick);
                                Messenger.PlayerMsg(client, time.TotalSeconds.ToString(), Text.BrightGreen);
                                //}
                            }
                        }
                        break;
                    case "/tournyplayers":
                        {
                            Tournament tourny = client.Player.Tournament;
                            if (tourny != null)
                            {
                                if (tourny.RegisteredMembers[client] != null)
                                {
                                    if (tourny.RegisteredMembers[client].Admin)
                                    {
                                        tourny.PlayersNeeded = joinedArgs.ToInt();
                                        Messenger.PlayerMsg(client, "The current player requirement is: " + tourny.PlayersNeeded.ToString(), Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    case "/createtourny":
                        {
                            Tournament tourny = TournamentManager.CreateTournament(client, joinedArgs, "s1193", 10, 10);
                            tourny.AddCombatMap("s1194");
                        }
                        break;
                    case "/jointourny":
                        {
                            Tournament tourny = TournamentManager.Tournaments[joinedArgs.ToInt()];
                            tourny.RegisterPlayer(client);
                        }
                        break;
                    case "/estlevel":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                exPlayer.Get(client).ElectrolockLevel = joinedArgs.ToInt();
                                Messenger.PlayerMsg(client, "EST level set to: " + joinedArgs.ToInt(), Text.BrightGreen);
                            }
                        }
                        break;
                    case "/april":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                //TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
                                //DateTime easternTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, easternZone);

                                //var tomorrow1am = easternTime.AddDays(1).Date;
                                //double totalHours = (int)( tomorrow1am - easternTime).TotalHours;
                                //Messenger.PlayerMsg(client, "Time: " + totalHours.ToString(), Text.Red);

                            }
                            break;
                        }
                    case "/restartserver":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Admin))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }
                            Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Server] Server restart initiated by: " + client.Player.Name);
                            RestartServer();
                        }
                        break;
                    case "/checktime":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, joinedArgs + "'s total play time: " + n.Player.Statistics.TotalPlayTime.ToString(), Text.BrightGreen);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/lastlogin":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string playerName = command[1];

                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    IDataColumn[] columns = dbConnection.Database.RetrieveRow("characteristics", "CharID", "Name=\"" + playerName + "\"");
                                    if (columns != null)
                                    {
                                        string charID = (string)columns[0].Value;
                                        string lastLogin = (string)dbConnection.Database.RetrieveRow("character_statistics", "LastLogin", "CharID=\"" + charID + "\"")[0].Value;
                                        Messenger.PlayerMsg(client, playerName + "'s last login: "******"Staff", "[Info Request] " + client.Player.Name + " checked " + playerName + "'s last login");
                                    }
                                }
                            }

                        }
                        break;
                    case "/checkparty":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Party party = PartyManager.FindParty(client.Player.PartyID);
                                int onlineClients = 0;
                                if (party != null)
                                {
                                    foreach (Client client2 in party.GetOnlineMemberClients())
                                    {
                                        onlineClients++;
                                    }
                                    Messenger.PlayerMsg(client, "Members: " + onlineClients, Text.BrightBlue);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "No Party", Text.BrightBlue);
                                }
                            }
                        }
                        break;
                    case "/playtime":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                TimeSpan longestPlayTime = new TimeSpan();
                                string playerName = "";
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying())
                                    {
                                        TimeSpan currentTime = i.Player.Statistics.TotalPlayTime + (DateTime.UtcNow - i.Player.Statistics.LoginTime);
                                        if (currentTime > longestPlayTime)
                                        {
                                            playerName = i.Player.Name;
                                            longestPlayTime = currentTime;
                                        }
                                    }
                                }
                                Messenger.PlayerMsg(client, "Longest play time:\n" + playerName + " (" + longestPlayTime.ToString() + ")", Text.BrightBlue);
                            }
                        }
                        break;
                    case "/fastshutdown":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.PlayerMsg(client, "[SECRET] Fast shutdown started.", Text.BrightRed);
                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    foreach (Client i in ClientManager.GetClients())
                                    {
                                        if (i.IsPlaying())
                                        {
                                            i.Player.SaveCharacterData(dbConnection);
                                            i.Player.SavingLocked = true;
                                        }
                                    }
                                }

                                Messenger.PlayerMsg(client, "Everyone saved, shutting down...", Text.BrightRed);
                                Environment.Exit(0);
                            }
                        }
                        break;
                    case "/shutdown":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int waitingTime = 30;
                                string messageText = "";
                                if (!string.IsNullOrEmpty(joinedArgs))
                                {
                                    messageText = joinedArgs;
                                }
                                for (int i = waitingTime; i >= 1; i--)
                                {
                                    Server.Globals.ServerStatus = "Please prepare for a server shutdown for maintenance. It will begin in " + i + " seconds." + messageText;
                                    System.Threading.Thread.Sleep(1000);
                                }
                                Messenger.AdminMsg("[Staff] Server shutdown in progress... Saving all players...", Text.BrightBlue);
                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Server] Server shutdown initiated by: " + client.Player.Name);
                                Server.Globals.ServerStatus = "Saving your data... Please wait...";
                                try
                                {
                                    using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                    {
                                        foreach (Client i in ClientManager.GetClients())
                                        {
                                            if (i.IsPlaying())
                                            {
                                                i.Player.SaveCharacterData(dbConnection);
                                                i.Player.SavingLocked = true;

                                                Messenger.PlayerMsg(i, "You saved the game!", Text.BrightGreen);
                                            }
                                        }
                                    }
                                    Messenger.PlayerMsg(client, "Everyone has been saved!", Text.Yellow);
                                }
                                catch { }
                                System.Threading.Thread shutdownTimerThread = new System.Threading.Thread(delegate()
                                {
                                    waitingTime = 30;
                                    for (int i = waitingTime; i >= 1; i--)
                                    {
                                        Server.Globals.ServerStatus = "The server will be shutting down in " + i + " seconds.";
                                        System.Threading.Thread.Sleep(1000);
                                    }
                                    Environment.Exit(0);
                                }
                                );
                                shutdownTimerThread.Start();
                            }
                        }
                        break;
                    case "/warn*":
                    case "/warn":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(command[1], true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(command[1]);
                                }
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(n, "You have been warned by a staff member: " + command[2] /* + "\n-" + client.Player.Name*/, System.Drawing.Color.Orange);
                                    Messenger.AdminMsg("[Staff] " + client.Player.Name + " has warned " + n.Player.Name + ": " + command[2], Text.BrightBlue);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Warning Issued] " + client.Player.Name + " warned " + n.Player.Name + " with message: " + command[2]);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/getcharinfo":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    CharacterInformation charInfo = PlayerManager.RetrieveCharacterInformation(dbConnection, joinedArgs);
                                    if (charInfo != null)
                                    {
                                        Messenger.PlayerMsg(client, "Info for " + charInfo.Name + ":", Text.Yellow);
                                        Messenger.PlayerMsg(client, "Account: " + charInfo.Account, Text.Yellow);
                                        Messenger.PlayerMsg(client, "CharID: " + charInfo.ID, Text.Yellow);
                                        Messenger.PlayerMsg(client, "Char Slot: " + charInfo.Slot, Text.Yellow);
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Info Request] " + client.Player.Name + " checked the character information for: " + command[1]);
                                    }
                                }
                            }
                        }
                        break;
                    case "/clearjoblist":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    n.Player.JobList.JobList.Clear();
                                    Messenger.SendJobList(n);
                                    Messenger.PlayerMsg(n, "Your job list has been cleared!", Text.BrightGreen);
                                    Messenger.PlayerMsg(client, "You have cleared " + joinedArgs + "'s job list!", Text.BrightGreen);
                                    //Messenger.PlayerMsg(client, joinedArgs + " ID is: " + n.Player.CharID, Text.BrightGreen);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/void":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.PlayerWarpToVoid(client);
                            }
                        }
                        break;
                    case "/voidplayer*":
                    case "/voidplayer":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string playerName = command[1];
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(playerName);
                                }

                                if (n != null)
                                {
                                    Messenger.PlayerWarpToVoid(n);
                                    Messenger.GlobalMsg(n.Player.Name + " has been swallowed by the void...", Text.Red);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, playerName + " could not be found.", Text.Green);
                                }
                            }
                        }
                        break;
                    case "/unvoid":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {

                                string playerName = command[1];
                                Client n;
                                n = ClientManager.FindClient(playerName);
                                IMap map = n.Player.Map;
                                if (map.MapType == Enums.MapType.Void)
                                {
                                    Server.Maps.Void @void = map as Server.Maps.Void;
                                    @void.SafeExit = true;
                                    Messenger.PlayerWarp(n, 1015, 25, 25);
                                    Messenger.PlayerMsg(n, "You have been unvoided.", Text.BrightGreen);
                                    Messenger.PlayerMsg(client, playerName + " has been unvoided.", Text.BrightGreen);
                                }
                            }
                        }
                        break;
                    case "/getid":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, joinedArgs + " ID is: " + n.Player.CharID, Text.BrightGreen);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/regenboard":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                client.Player.MissionBoard.GenerateMission();
                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Missions] " + client.Player.Name + " regenerated their mission board.");
                            }
                        }
                        break;
                    case "/who":
                        {
                            int count = 0;
                            foreach (Client i in ClientManager.GetClients())
                            {
                                if (i.TcpClient.Socket.Connected && i.IsPlaying())
                                {
                                    count++;
                                }
                            }
                            Messenger.PlayerMsg(client, "Players online: " + count, Text.Yellow);
                        }
                        break;
                    case "/saveall":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    try
                                    {
                                        foreach (Client i in ClientManager.GetClients())
                                        {
                                            i.Player.SaveCharacterData(dbConnection);
                                            Messenger.PlayerMsg(i, "You saved the game!", Text.BrightGreen);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Messenger.PlayerMsg(client, ex.ToString(), Text.BrightRed);
                                    }
                                }
                                Messenger.PlayerMsg(client, "Everyone has been saved!", Text.Yellow);
                            }
                        }
                        break;
                    case "/isveteran":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, n.Player.Veteran.ToString(), Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/explode":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.GlobalMsg(client.Player.Name + " has exploded.", Text.BrightRed);
                            }
                        }
                        break;

                    case "/silentkick*":
                    case "/silentkick":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string playerName = command[1];
                                Client kickedClient;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    kickedClient = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    kickedClient = ClientManager.FindClient(playerName);
                                }
                                if (kickedClient != null)
                                {
                                    if (command.CommandArgs.Count > 2 && !String.IsNullOrEmpty(command[2]))
                                    {
                                        Messenger.AdminMsg("[Staff] " + kickedClient.Player.Name + " has been disconnected silently from the server by " + client.Player.Name + "! " + "Reason: " + command[2], Text.BrightBlue);
                                        kickedClient.CloseConnection();
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Kick] " + client.Player.Name + " silently kicked " + playerName + " from the server with reason: " + command[2]);
                                    }
                                    else
                                    {
                                        Messenger.AdminMsg("[Staff] " + kickedClient.Player.Name + " has been disconnected silently from the server by " + client.Player.Name + "!", Text.BrightBlue);
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Kick] " + client.Player.Name + " silently kicked " + playerName + " from the server.");
                                        kickedClient.CloseConnection();
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Unable to find player!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "/kick*":
                    case "/kick":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string playerName = command[1];
                                Client kickedClient;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    kickedClient = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    kickedClient = ClientManager.FindClient(playerName);
                                }
                                if (kickedClient != null)
                                {
                                    if (command.CommandArgs.Count > 2 && !String.IsNullOrEmpty(command[2]))
                                    {
                                        Messenger.AdminMsg(kickedClient.Player.Name + " has been kicked from the server by " + client.Player.Name + "!" + " Reason: " + command[2], Text.BrightBlue);
                                        Messenger.PlainMsg(kickedClient, "You have been kicked from the server!  Reason: " + command[2], Enums.PlainMsgType.MainMenu);
                                        kickedClient.CloseConnection();
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Kick] " + client.Player.Name + " kicked " + playerName + " from the server with reason: " + command[2]);
                                    }
                                    else
                                    {
                                        Messenger.AdminMsg("[Staff] " + kickedClient.Player.Name + " has been kicked from the server by " + client.Player.Name, Text.BrightBlue);
                                        Messenger.PlainMsg(kickedClient, "You have been kicked from the server!", Enums.PlainMsgType.MainMenu);
                                        kickedClient.CloseConnection();
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Kick] " + client.Player.Name + " kicked " + playerName + " from the server.");
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Unable to find player!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "/ban*":
                    case "/ban":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string playerName = command[1];
                                string banTimeDays = "-----";
                                Client bannedClient;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    bannedClient = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    bannedClient = ClientManager.FindClient(playerName);
                                }

                                if (command.CommandArgs.Count > 2 && command[2].IsNumeric())
                                {
                                    banTimeDays = DateTime.Now.AddDays(Convert.ToDouble(command[2])).ToString();
                                }

                                if (bannedClient != null)
                                {
                                    using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                    {
                                        Bans.BanPlayer(dbConnection, bannedClient.IP.ToString(), bannedClient.Player.CharID,
                                            bannedClient.Player.AccountName + "/" + bannedClient.Player.Name, bannedClient.MacAddress, bannedClient.BiosId,
                                            client.Player.CharID, client.IP.ToString(), banTimeDays, Enums.BanType.Ban);
                                        Messenger.AdminMsg("[Staff] " + bannedClient.Player.Name + " has been banned by " + client.Player.Name + "!", Text.BrightBlue);
                                        PlayerInfoReport(bannedClient);
                                        Messenger.PlainMsg(bannedClient, "You have been banned!", Enums.PlainMsgType.MainMenu);
                                        bannedClient.CloseConnection();
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Ban] " + client.Player.Name + " banned " + playerName + ".");
                                    }
                                }
                                else
                                {
                                    using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                    {
                                        IDataColumn[] columns = dbConnection.Database.RetrieveRow("characteristics", "CharID", "Name=\"" + playerName + "\"");
                                        if (columns != null)
                                        {
                                            string charID = (string)columns[0].Value;
                                            string foundIP = (string)dbConnection.Database.RetrieveRow("character_statistics", "LastIPAddressUsed", "CharID=\"" + charID + "\"")[0].Value;
                                            string foundMac = (string)dbConnection.Database.RetrieveRow("character_statistics", "LastMacAddressUsed", "CharID=\"" + charID + "\"")[0].Value;
                                            string storedUUID = (string)dbConnection.Database.RetrieveRow("character_statistics", "StoredUUID", "CharID=\"" + charID + "\"")[0].Value;
                                            //get previous IP and mac
                                            Bans.BanPlayer(dbConnection, foundIP, charID, playerName, foundMac, storedUUID,
                                                client.Player.CharID, client.IP.ToString(), banTimeDays, Enums.BanType.Ban);
                                            Messenger.AdminMsg("[Staff] " + bannedClient.Player.Name + " has been banned by " + client.Player.Name + "!", Text.BrightBlue);
                                            Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Ban] " + client.Player.Name + " banned " + playerName + ".");
                                        }
                                        else
                                        {
                                            Messenger.PlayerMsg(client, "Unable to find player!", Text.BrightRed);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "/htest":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.OpenVisitHouseMenu(client);
                            }
                        }
                        break;
                    case "/emptyhouse":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                            {
                                List<Client> clientList = new List<Client>();

                                foreach (Client n in client.Player.Map.GetClients())
                                {
                                    if (n != client && Ranks.IsDisallowed(client, Enums.Rank.Moniter))
                                    {
                                        clientList.Add(n);
                                    }
                                }

                                foreach (Client n in clientList)
                                {
                                    if (!string.IsNullOrEmpty(exPlayer.Get(n).HousingCenterMap))
                                    {
                                        Messenger.PlayerWarp(n, exPlayer.Get(n).HousingCenterMap, exPlayer.Get(n).HousingCenterX, exPlayer.Get(n).HousingCenterY);
                                    }
                                }
                                Messenger.PlayerMsg(client, "All visitors have been kicked from your house!", Text.Yellow);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You aren't in your house!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/leavehouse":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType == Server.Enums.MapType.House)
                            {
                                if (!string.IsNullOrEmpty(exPlayer.Get(client).HousingCenterMap))
                                {
                                    Messenger.PlayerWarp(client, exPlayer.Get(client).HousingCenterMap, exPlayer.Get(client).HousingCenterX, exPlayer.Get(client).HousingCenterY);
                                }
                            }
                        }
                        break;
                    case "/houseentrance":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                            {
                                //Messenger.AskQuestion(client, "HouseSpawn", "Will you set your house's entrance here?", -1);
                                Messenger.AskQuestion(client, "HouseSpawn", "Will you set your house's entrance here?  It will cost 500 Poké.", -1);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't set your house entrance here!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/houseroof":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                            {
                                if (map.Indoors)
                                {
                                    Messenger.AskQuestion(client, "HouseRoof", "Will you open your house's roof and expose it to time and weather conditions?  It will cost 500 Poké.", -1);
                                }
                                else
                                {
                                    Messenger.AskQuestion(client, "HouseRoof", "Will you close your house to time and weather conditions?  It will cost 500 Poké.", -1);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't set your house roof here!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/houseweather":
                        {
                            IMap map = client.Player.Map;
                            if (client.Player.ExplorerRank >= Enums.ExplorerRank.Silver)
                            {
                                if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                                {
                                    if (map.Indoors)
                                    {
                                        Messenger.PlayerMsg(client, "You can't set your house weather unless you open your house with /houseroof", Text.BrightRed);
                                    }
                                    else
                                    {
                                        Messenger.OpenChangeWeatherMenu(client);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You can't set your house weather here!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house until your Explorer Rank is Silver or higher.", Text.BrightRed);
                            }
                        }
                        break;
                    case "/houselight":
                        {
                            IMap map = client.Player.Map;
                            if (client.Player.ExplorerRank >= Enums.ExplorerRank.Silver)
                            {
                                if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                                {
                                    Messenger.OpenChangeDarknessMenu(client);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You can't set your house lights here!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house until your Explorer Rank is Silver or higher.", Text.BrightRed);
                            }
                        }
                        break;
                    case "/houseexpand":
                        {
                            IMap map = client.Player.Map;
                            if (client.Player.ExplorerRank >= Enums.ExplorerRank.Gold)
                            {
                                if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                                {
                                    Messenger.OpenChangeBoundsMenu(client);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You can't expand your house here!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house until your Explorer Rank is Gold or higher.", Text.BrightRed);
                            }
                        }
                        break;
                    case "/houseshop":
                        {
                            IMap map = client.Player.Map;
                            if (client.Player.ExplorerRank >= Enums.ExplorerRank.Bronze)
                            {
                                if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                                {
                                    Messenger.OpenAddShopMenu(client);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You can't place a shop here!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house until your Explorer Rank is Bronze or higher.", Text.BrightRed);
                            }
                        }
                        break;
                    case "/housesign":
                        {
                            IMap map = client.Player.Map;
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            if (client.Player.ExplorerRank >= Enums.ExplorerRank.Bronze)
                            {
                                if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                                {
                                    Messenger.OpenAddSignMenu(client);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You can't place a sign here!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house until your Explorer Rank is Bronze or higher.", Text.BrightRed);
                            }
                        }
                        break;
                    case "/housesound":
                        {
                            IMap map = client.Player.Map;
                            if (client.Player.ExplorerRank >= Enums.ExplorerRank.Bronze)
                            {
                                if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                                {
                                    Messenger.OpenAddSoundMenu(client);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You can't place a sound tile here!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house until your Explorer Rank is Bronze or higher.", Text.BrightRed);
                            }
                        }
                        break;
                    case "/housenotice":
                        {
                            IMap map = client.Player.Map;
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            if (client.Player.ExplorerRank >= Enums.ExplorerRank.Bronze)
                            {
                                if (map.MapType == Server.Enums.MapType.House && ((House)map).OwnerID == client.Player.CharID)
                                {
                                    Messenger.OpenAddNoticeMenu(client);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You can't place a notice tile here!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house until your Explorer Rank is Bronze or higher.", Text.BrightRed);
                            }
                        }
                        break;

                    //test2

                    case "/darktest":
                        {
                            /*if (Ranks.IsAllowed(client, Enums.Rank.Scripter)) {
                                foreach (Client i in ClientManager.GetClients()) {
                                    if (i.IsPlaying() && i.Player.AccountName == "Dandy") {
                                        i.Player.Access = Enums.Rank.Mapper;
                                    }
                                }
                            }*/
                            break;
                        }

                    //mapkill

                    case "/kipz":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                if (client.Player.MapID == MapManager.GenerateMapID(1129))
                                {
                                    IMap map = client.Player.Map;
                                    foreach (Client i in map.GetClients())
                                    {
                                        StoryManager.PlayStory(i, 94);
                                    }
                                }
                            }
                        }
                        break;
                    case "/stafflist":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.PlayerMsg(client, "The staff that are currently online are:", Text.Green);
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (Ranks.IsAllowed(i, Enums.Rank.Moniter))
                                    {
                                        Messenger.PlayerMsg(client, "(" + i.Player.Access.ToString() + ")" + i.Player.Name, Text.Green);
                                    }
                                }
                            }
                        }
                        break;
                    case "/isitrandom":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int rand = Server.Math.Rand(0, 10);
                                Messenger.PlayerMsg(client, rand.ToString(), Text.Green);

                            }
                        }
                        break;
                    case "/rdungeonscriptgoal":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                RDungeonScriptGoal(client, joinedArgs.ToInt(), 0, 0);
                            }
                        }
                        break;
                    case "/fdh":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                for (int i = 1; i <= 2000; i++)
                                {
                                    //for (int x = 0; x <= MapManager.RetrieveMapGeneralInfo(i).MaxX; x++) {
                                    //    for (int y = 0; y <= MapManager.RetrieveMapGeneralInfo(i).MaxY; y++) {
                                    // TODO: map tile info [Scripts]
                                    /* Can't get info on a nonactive map's tiles...
                                    if (NetScript.GetAttribute(i, x, y) == Enums.TileType.Shop /*|| NetScript.GetAttribute(i, x, y) == Enums.TileType.Warp) {
                                        if (NetScript.GetTileData1(i, x, y) == /*243 joinedArg.ToInt()) {
                                            NetScript.PlayerMsg(client, "Found warp! On Map " + i.ToString() + " X: " + x.ToString() + " Y: " + y.ToString(), Text.Yellow);
                                            //return;
                                        }
                                    }
                                    */
                                    //    }
                                    //}
                                }
                            }
                        }
                        break;
                    case "/findaccount":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.Player.AccountName.ToLower() == joinedArgs.ToLower())
                                    {
                                        Messenger.PlayerMsg(client, "Found account! [" + i.Player.AccountName + "/" + i.Player.Name + "]", Text.BrightGreen);
                                    }
                                }
                            }
                        }
                        break;
                    case "/cc":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                n.CloseConnection();
                                Messenger.PlayerMsg(client, "CC/ " + n.Player.Name, Text.Blue);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "That is not a valid command!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/regenlotto":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Lottery.ForceGenLottoNumbers();
                                Messenger.PlayerMsg(client, "Lottery numbers regenerated!", Text.Yellow);
                            }
                        }
                        break;
                    case "/lottostats":
                        {
                            // TODO: /lottostats lottery
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.PlayerMsg(client, "Lottery Stats:", Text.BrightGreen);
                                Messenger.PlayerMsg(client, "Lottery Payout: " + Lottery.LotteryPayout, Text.BrightGreen);
                                Messenger.PlayerMsg(client, "Lottery Earnings: " + Lottery.LotteryEarnings, Text.BrightGreen);
                                Messenger.PlayerMsg(client, "Last Lottery Earnings: " + Lottery.LastLotteryEarnings, Text.BrightGreen);
                                Messenger.PlayerMsg(client, "Total Lottery Earnings: " + Lottery.TotalLotteryEarnings, Text.BrightGreen);
                            }
                        }
                        break;
                    //debug
                    //testbuff
                    case "/playeros":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                Messenger.PlayerMsg(client, n.Player.Name + " OS info:", Text.Yellow);
                                Messenger.PlayerMsg(client, n.Player.GetOSVersion(), Text.Yellow);
                                Messenger.PlayerMsg(client, ".NET info:", Text.Yellow);
                                Messenger.PlayerMsg(client, n.Player.GetDotNetVersion(), Text.Yellow);
                                Messenger.PlayerMsg(client, "Client info:", Text.Yellow);
                                Messenger.PlayerMsg(client, n.Player.GetClientEdition(), Text.Yellow);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "That is not a valid command!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/lounge":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.PlayerWarp(client, 1466, 39, 21);
                                Messenger.PlayerMsg(client, "Welcome to the staff headquarters!", Text.Yellow);
                                //110
                            }
                        }
                        break;
                    case "/gccollect":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                GC.Collect();
                                Messenger.PlayerMsg(client, "Garbage collected!", Text.BrightGreen);
                            }
                        }
                        break;
                    case "/adminmsg":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                //DatabaseManager.OptionsDB.SaveSetting("Generic", "AdminMsg", joinedArgs);
                                //Messenger.PlayerMsg(client, "Admin message changed to: \"" + joinedArgs + "\"", Text.BrightGreen);
                            }
                        }
                        break;
                    case "/motd":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                Server.Settings.MOTD = joinedArgs;
                                Messenger.GlobalMsg("MOTD changed to: " + joinedArgs, Text.BrightCyan);
                                Server.Settings.SaveMOTD();
                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[MOTD] " + client.Player.Name + " set the MOTD to: " + joinedArgs);
                            }
                        }
                        break;

                    #region CTF Commands
                    case "/ctfcreate":
                        {
                            if (client.Player.MapID == MapManager.GenerateMapID(CTF.HUBMAP))
                            {
                                if (ActiveCTF == null)
                                {
                                    ActiveCTF = new CTF(CTF.CTFGameState.NotStarted);
                                }
                                if (ActiveCTF.GameState == CTF.CTFGameState.NotStarted)
                                {
                                    ActiveCTF.CreateGame(client);
                                    return;
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "A game of Capture The Flag is already started!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "/ctfjoin":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You cannot join the game because you are muted!", Text.BrightRed);
                            }
                            if (client.Player.MapID == MapManager.GenerateMapID(CTF.HUBMAP))
                            {
                                if (ActiveCTF == null)
                                {
                                    Messenger.PlayerMsg(client, "No game has been started yet!", Text.BrightRed);
                                }
                                else if (ActiveCTF.GameState == CTF.CTFGameState.WaitingForPlayers)
                                {
                                    if (exPlayer.Get(client).InCTF == false)
                                    {
                                        ActiveCTF.AddToGame(client);
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "You have already joined the game!", Text.BrightRed);
                                    }
                                }
                                else
                                {
                                    if (ActiveCTF.GameState == CTF.CTFGameState.Started)
                                    {
                                        Messenger.PlayerMsg(client, "There is already a game of Capture The Flag that has been started!", Text.BrightRed);
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "No game of Capture The Flag has been created yet!", Text.BrightRed);
                                    }
                                }
                            }
                        }
                        break;
                    case "/ctfleave":
                        {
                            if (client.Player.MapID == MapManager.GenerateMapID(CTF.REDMAP) || client.Player.MapID == MapManager.GenerateMapID(CTF.BLUEMAP))
                            {
                                ActiveCTF.RemoveFromGame(client);
                            }
                        }
                        break;
                    case "/ctfstart":
                        {
                            if (ActiveCTF.GameLeader == client)
                            {
                                ActiveCTF.StartGame();
                                ActiveCTF.CTFMsg("This game of Capture The Flag has started.", Text.Yellow);
                                ActiveCTF.CTFMsg("This game will have " + ActiveCTF.BlueFlags + " flags!", Text.Yellow);
                            }
                        }
                        break;
                    case "/ctfflags":
                        {
                            if (ActiveCTF.GameLeader == client && ActiveCTF.GameState == CTF.CTFGameState.WaitingForPlayers)
                            {
                                ActiveCTF.RedFlags = joinedArgs.ToInt();
                                ActiveCTF.BlueFlags = joinedArgs.ToInt();
                                Messenger.PlayerMsg(client, "This game will have " + ActiveCTF.BlueFlags + " flags!", Text.Yellow);
                            }
                        }
                        break;
                    case "/ctfend":
                        {
                            if (ActiveCTF.GameLeader == client)
                            {
                                ActiveCTF.EndGame(client);
                                Messenger.PlayerMsg(client, "You have ended the game.", Text.Yellow);
                            }
                        }
                        break;
                    case "/ctfforceend":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                ActiveCTF.EndGame(client.Player.Name);
                                Messenger.PlayerMsg(client, "You have ended the game.", Text.Yellow);
                            }
                        }
                        break;
                    case "/ctf":
                        {
                            if (ActiveCTF.GameState == CTF.CTFGameState.Started)
                            {
                                if (exPlayer.Get(client).InCTF)
                                {
                                    ActiveCTF.CTFMsg(client.Player.Name + " [CTF]: " + joinedArgs, Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/ctft":
                        {
                            if (ActiveCTF.GameState == CTF.CTFGameState.Started)
                            {
                                if (exPlayer.Get(client).InCTF)
                                {
                                    ActiveCTF.CTFTMsg(client, client.Player.Name + " [CTF Team]: " + joinedArgs, Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/ctfgen":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                RDungeonMap dungeonMap = RDungeonFloorGen.GenerateFloor(client, 39, 0, RDungeonManager.RDungeons[39].Floors[0].Options);
                                Messenger.PlayerWarp(client, dungeonMap, dungeonMap.StartX, dungeonMap.StartY);
                            }
                        }
                        break;
                    #endregion CTF Commands
                    case "/checkstack":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(command[1]);
                                if (n == null)
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                                else if (command[2].ToInt() <= 0)
                                {
                                    Messenger.PlayerMsg(client, "Invalid item number.", Text.BrightRed);
                                }
                                else if (n == client)
                                {
                                    Messenger.PlayerMsg(client, "Your amount of " + ItemManager.Items[command[2].ToInt()].Name + ": " + n.Player.HasItem(command[2].ToInt()).ToString(), Text.Yellow);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s amount of " + ItemManager.Items[command[2].ToInt()].Name + ": " + n.Player.HasItem(command[2].ToInt()).ToString(), Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/checkinv*":
                    case "/checkinv":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(joinedArgs, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(joinedArgs);
                                }
                                Messenger.PlayerMsg(client, n.Player.Name + "'s Inventory:", Text.Yellow);
                                InventoryItem item;
                                for (int i = 1; i <= n.Player.MaxInv; i++)
                                {
                                    item = n.Player.Inventory[i];
                                    int amount = 0;
                                    string msg = item.Num + " ";
                                    if (item.Num > 0)
                                    {
                                        msg += ItemManager.Items[item.Num].Name;
                                        amount = item.Amount;
                                    }
                                    if (amount > 0)
                                    {
                                        msg += " (" + amount.ToString() + ")";
                                    }
                                    if (item.Tag != "")
                                    {
                                        msg += " [" + item.Tag + "]";
                                    }
                                    if (msg != "")
                                    {
                                        Messenger.PlayerMsg(client, msg, Text.Yellow);
                                    }
                                }
                            }
                        }
                        break;
                    case "/clearinv":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                for (int i = 1; i <= client.Player.MaxInv; i++)
                                {
                                    client.Player.TakeItemSlot(i, client.Player.Inventory[i].Amount, true);
                                }
                                Messenger.PlayerMsg(client, "Inventory Cleared", Text.Yellow);
                            }
                        }
                        break;
                    case "/checkbank*":
                    case "/checkbank":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(joinedArgs, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(joinedArgs);
                                }
                                Messenger.PlayerMsg(client, n.Player.Name + "'s Bank:", Text.Yellow);
                                InventoryItem item;
                                for (int i = 1; i <= n.Player.MaxBank; i++)
                                {
                                    item = n.Player.Bank[i];
                                    int amount = 0;
                                    string msg = "";
                                    if (item.Num > 0)
                                    {
                                        msg = ItemManager.Items[item.Num].Name;
                                        amount = item.Amount;
                                    }
                                    if (amount > 0)
                                    {
                                        msg += " (" + amount.ToString() + ")";
                                    }
                                    if (msg != "")
                                    {
                                        Messenger.PlayerMsg(client, msg, Text.Yellow);
                                    }
                                }
                            }
                        }
                        break;
                    case "/checktile":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Tile tile = client.Player.Map.Tile[client.Player.X, client.Player.Y];
                                Messenger.PlayerMsg(client, tile.Type.ToString(), Text.Yellow);
                                Messenger.PlayerMsg(client, "Ground: " + tile.GroundSet + ":" + tile.Ground, Text.Yellow);
                                Messenger.PlayerMsg(client, "GroundAnim: " + tile.GroundAnimSet + ":" + tile.GroundAnim, Text.Yellow);
                                Messenger.PlayerMsg(client, "Mask: " + tile.MaskSet + ":" + tile.Mask, Text.Yellow);
                                Messenger.PlayerMsg(client, "MaskAnim: " + tile.AnimSet + ":" + tile.Anim, Text.Yellow);
                                Messenger.PlayerMsg(client, "Mask2: " + tile.Mask2Set + ":" + tile.Mask2, Text.Yellow);
                                Messenger.PlayerMsg(client, "Mask2Anim: " + tile.M2AnimSet + ":" + tile.M2Anim, Text.Yellow);
                                Messenger.PlayerMsg(client, "Fringe: " + tile.FringeSet + ":" + tile.Fringe, Text.Yellow);
                                Messenger.PlayerMsg(client, "FringeAnim: " + tile.FAnimSet + ":" + tile.FAnim, Text.Yellow);
                                Messenger.PlayerMsg(client, "Fringe2: " + tile.Fringe2Set + ":" + tile.Fringe2, Text.Yellow);
                                Messenger.PlayerMsg(client, "Fringe2Anim: " + tile.F2AnimSet + ":" + tile.F2Anim, Text.Yellow);
                                Messenger.PlayerMsg(client, "Data1: " + tile.Data1, Text.Yellow);
                                Messenger.PlayerMsg(client, "Data2: " + tile.Data2, Text.Yellow);
                                Messenger.PlayerMsg(client, "Data3: " + tile.Data3, Text.Yellow);
                                Messenger.PlayerMsg(client, "String1: " + tile.String1, Text.Yellow);
                                Messenger.PlayerMsg(client, "String2: " + tile.String2, Text.Yellow);
                                Messenger.PlayerMsg(client, "String3: " + tile.String3, Text.Yellow);
                            }
                        }
                        break;
                    case "/checkmoves":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                Messenger.PlayerMsg(client, n.Player.Name + "'s Moves:", Text.Yellow);
                                for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++)
                                {
                                    if (n.Player.Team[i] != null && n.Player.Team[i].Loaded)
                                    {
                                        Messenger.PlayerMsg(client, "Team #" + i + ": " + Pokedex.GetPokemon(n.Player.Team[i].Species).Name, Text.Yellow);
                                        for (int j = 0; j < 4; j++)
                                        {
                                            if (n.Player.Team[i].Moves[j].MoveNum > 0)
                                            {
                                                Messenger.PlayerMsg(client, MoveManager.Moves[n.Player.Team[i].Moves[j].MoveNum].Name, Text.Yellow);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "/checkmissions":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                Messenger.PlayerMsg(client, n.Player.Name + "'s Mission Board:", Text.Yellow);
                                foreach (WonderMail mail in n.Player.MissionBoard.BoardMissions)
                                {
                                    Messenger.PlayerMsg(client, mail.Title, Text.Yellow);
                                }
                                Messenger.PlayerMsg(client, n.Player.Name + "'s Job List:", Text.Yellow);
                                foreach (WonderMailJob job in n.Player.JobList.JobList)
                                {
                                    Messenger.PlayerMsg(client, job.Mission.Title, Text.Yellow);
                                }
                            }
                        }
                        break;
                    //checkpts ~ what pts? THERE ARE NO PTS ANYMORE
                    #region Auction Commands
                    case "/masswarpauction":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    Messenger.AskQuestion(i, "MassWarpAuction", client.Player.Name + " is inviting you to join an auction!  Would you like to play?", -1);
                                }
                            }
                        }
                        break;
                    case "/createauction":
                        {
                            if (client.Player.MapID == Auction.AUCTION_MAP)
                            {
                                if (!Auction.StaffAuction)
                                {
                                    Auction.CreateAuction(client);
                                }
                                else if (Auction.StaffAuction && Ranks.IsAllowed(client, Enums.Rank.Mapper))
                                {
                                    Auction.CreateAuction(client);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "A staff held auction is in progress. You may not create an auction at this time!", Text.BrightRed);
                                }

                            }

                        }
                        break;
                    case "/startauction":
                        {
                            Auction.StartAuction(client);
                        }
                        break;
                    case "/endauction":
                        {
                            Auction.EndAuction(client);
                        }
                        break;
                    case "/auctionadminhelp":
                        {
                            Auction.SayHelp(client);
                        }
                        break;
                    case "/auctionhelp":
                        {
                            Auction.SayPlayerHelp(client);
                        }
                        break;
                    case "/checkbidder":
                        {
                            Auction.CheckBidder(client);
                        }
                        break;
                    case "/setauctionitem":
                        {
                            Auction.SetAuctionItem(client, joinedArgs);
                        }
                        break;
                    case "/setauctionminbid":
                        {
                            Auction.SetAuctionMinBid(client, joinedArgs.ToInt());
                        }
                        break;
                    case "/setbidincrement":
                        {
                            Auction.SetBidIncrement(client, joinedArgs.ToInt());
                        }
                        break;
                    case "/bid":
                        {
                            if (client.Player.HasItem(1) >= joinedArgs.ToInt())
                            {
                                Auction.UpdateBids(client, joinedArgs.ToInt());
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You don't have enough Poké!", Text.BrightRed);
                            }
                        }
                        break;

                    #endregion Auction Commands
                    case "/reward":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                foreach (Client i in client.Player.Map.GetClients())
                                {
                                    //	i.Player.GiveItem(746, 1);
                                    i.Player.GiveItem(133, 3);
                                    Messenger.PlayerMsg(i, "You have been awarded three event tokens for participating!", Text.BrightGreen);
                                }
                            }
                        }
                        break;
                    case "/givetokens":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n;
                                n = ClientManager.FindClient(command[1]);
                                int numTokens = command[2].ToInt();

                                n.Player.GiveItem(133, numTokens);
                                Messenger.PlayerMsg(n, client.Player.Name + " has awarded you " + numTokens + " event tokens!", Text.BrightGreen);
                                Messenger.AdminMsg("[Staff] " + client.Player.Name + " has given " + n.Player.Name + " " + numTokens + " event tokens!", Text.BrightBlue);
                            }
                        }
                        break;
                    case "/setname*":
                    case "/setname":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                Client n;
                                string newName = command[2];
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(command[1], true); // Attempt to find our player if they have a difficult name
                                }
                                else
                                {
                                    n = ClientManager.FindClient(command[1]);
                                }

                                n.Player.Name = newName;
                                Messenger.SendPlayerData(n);
                            }
                        }
                        break;

                    case "/setguild":
                        {
                            try
                            {
                                if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                                {
                                    using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                    {
                                        Client n = ClientManager.FindClient(command[1]);
                                        string guildName = command[2];
                                        if (n != null)
                                        {
                                            // DataManager.Players.PlayerDataManager.AddGuildMember(dbConnection.Database, guildName, n.Player.CharID);
                                            // DataManager.Players.PlayerDataManager.SetGuildAccess(dbConnection.Database, n.Player.CharID, (int)Enums.GuildRank.Founder);
                                            // n.Player.GuildName = guildName;
                                            //  n.Player.GuildAccess = Enums.GuildRank.Founder;

                                            // DataManager.Players.PlayerDataManager.RemoveGuildMember(dbConnection.Database, n.Player.CharID);
                                            n.Player.GuildName = command[2];
                                            // n.Player.GuildAccess = Enums.GuildRank.None;

                                            Messenger.SendPlayerGuild(n);
                                        }
                                    }
                                }
                            }
                            catch (Exception ex) { }
                        }
                        break;
                    //case "/checkowner": {
                    //        if (Ranks.IsAllowed(client, Enums.Rank.Moniter)) {
                    //            if (client.Player.Map.Owner != null) {
                    //                Messenger.PlayerMsg(client, "The owner of this place is: " + client.Player.Map.Owner, Text.Yellow);
                    //            }
                    //        }
                    //    }
                    //    break;
                    //blockpm
                    //closeserver
                    //closeall
                    //closenonplayers

                    case "/hb":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                string playerMap = client.Player.MapID;
                                Messenger.MapMsg(playerMap, "H", Text.Blue);
                                Messenger.MapMsg(playerMap, "A", Text.Green);
                                Messenger.MapMsg(playerMap, "P", Text.Cyan);
                                Messenger.MapMsg(playerMap, "P", Text.Red);
                                Messenger.MapMsg(playerMap, "Y", Text.Magenta);
                                Messenger.MapMsg(playerMap, "-", Text.Grey);
                                Messenger.MapMsg(playerMap, "B", Text.Brown);
                                Messenger.MapMsg(playerMap, "I", Text.BrightBlue);
                                Messenger.MapMsg(playerMap, "R", Text.BrightGreen);
                                Messenger.MapMsg(playerMap, "T", Text.BrightCyan);
                                Messenger.MapMsg(playerMap, "H", Text.BrightRed);
                                Messenger.MapMsg(playerMap, "D", Text.Pink);
                                Messenger.MapMsg(playerMap, "A", Text.Yellow);
                                Messenger.MapMsg(playerMap, "Y", Text.Blue);
                                Messenger.MapMsg(playerMap, joinedArgs + "!", Text.White);
                                Messenger.PlaySoundToMap(client.Player.MapID, "magic7.wav");
                            }
                        }
                        break;
                    case "/pk":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    Client n = ClientManager.FindClient(joinedArgs);
                                    if (n != null)
                                    {
                                        //n.Player.PK = !n.Player.PK;
                                        Messenger.SendPlayerData(n);
                                    }
                                }
                            }
                        }
                        break;
                    case "/eat":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    Client n = ClientManager.FindClient(joinedArgs);
                                    if (n != null)
                                    {
                                        Messenger.GlobalMsg(client.Player.Name + " has eaten " + n.Player.Name + "!", Text.Yellow);
                                        Messenger.PlayerWarp(n, 509, 11, 8);
                                        //} else if (n == index) {
                                        //    NetScript.PlayerMsg(index, "You cant eat yourself!", Text.BrightRed);
                                    }
                                    else if (n == null)
                                    {
                                        Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You have to pick somebody to eat!", Text.Black);
                                }
                            }
                        }
                        break;
                    case "/._.":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    Client n = ClientManager.FindClient(joinedArgs);
                                    if (n != null)
                                    {
                                        Messenger.GlobalMsg(client.Player.Name + " has stared into the eternal soul of " + n.Player.Name + "!", System.Drawing.Color.MidnightBlue);
                                        Messenger.PlayerWarp(n, 2000, 9, 6);
                                        //} else if (n == index) {
                                        //    NetScript.PlayerMsg(index, "You cant eat yourself!", Text.BrightRed);
                                    }
                                    else if (n == null)
                                    {
                                        Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You have to pick somebody to stare into the eternal soul of!", Text.Black);
                                }
                            }
                        }
                        break;
                    case "/addnews":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    try
                                    {
                                        Server.Settings.AddNews(joinedArgs);
                                        Messenger.GlobalMsg("Updated News: " + joinedArgs, Text.Yellow);
                                    }
                                    catch (Exception ex)
                                    {
                                        Messenger.PlayerMsg(client, ex.ToString(), Text.Red);
                                    }
                                    Messenger.PlayerMsg(client, "News updated!", Text.Yellow);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "The new news cant be blank!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "/reloadnews":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                Server.Settings.LoadNews();
                                Messenger.PlayerMsg(client, "News have been reloaded!", Text.Yellow);
                            }
                        }
                        break;
                    case "/news":
                        {
                            Messenger.PlayerMsg(client, "Latest News:", Text.Yellow);
                            for (int i = 0; i < Server.Settings.News.Count; i++)
                            {
                                Messenger.PlayerMsg(client, Server.Settings.News[i], Text.Yellow);
                            }

                        }
                        break;
                    case "/givemove":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Developer))
                            {
                                Client n = ClientManager.FindClient(command[1]);
                                if (n != null)
                                {
                                    int moveNum;
                                    if (command[2].IsNumeric() && command[2].ToInt() > 1 && command[2].ToInt() <= MoveManager.Moves.MaxMoves)
                                    {
                                        moveNum = command[2].ToInt();
                                        n.Player.GetActiveRecruit().LearnNewMove(moveNum);
                                        Messenger.PlayerMsg(client, "You have taught " + n.Player.Name + " the move " + MoveManager.Moves[moveNum].Name, Text.Yellow);
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Move Given] " + client.Player.Name + " gave " + n.Player.Name + " the move " + MoveManager.Moves[moveNum].Name);

                                    }
                                    else
                                    {
                                        moveNum = -1;
                                        for (int i = 1; i <= MoveManager.Moves.MaxMoves; i++)
                                        {
                                            if (MoveManager.Moves[i].Name.ToLower().StartsWith(command[2].ToLower()))
                                            {
                                                moveNum = i;
                                            }
                                        }
                                        if (moveNum > -1)
                                        {

                                            n.Player.GetActiveRecruit().LearnNewMove(moveNum);
                                            Messenger.PlayerMsg(client, "You have taught " + n.Player.Name + " the move " + MoveManager.Moves[moveNum].Name, Text.Yellow);
                                            Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Move Given] " + client.Player.Name + " gave " + n.Player.Name + " the move " + MoveManager.Moves[moveNum].Name);
                                        }
                                    }
                                    Messenger.SendPlayerMoves(n);
                                }
                            }
                        }
                        break;
                    //global
                    //fakeadmin
                    //serverontime, obsolete
                    case "/hunt":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (client.Player.ProtectionOff)
                                {
                                    client.Player.ProtectionOff = false;
                                    client.Player.Hunted = false;
                                    Messenger.PlayerMsg(client, "You are no longer hunted.", Text.BrightGreen);
                                }
                                else
                                {
                                    client.Player.ProtectionOff = true;
                                    client.Player.Hunted = true;
                                    Messenger.PlayerMsg(client, "You are now hunted.", Text.BrightGreen);
                                }
                                PacketBuilder.AppendHunted(client, hitlist);
                            }
                        }
                        break;
                    case "/learnmove":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                int move = command[1].ToInt();
                                if (move <= MoveManager.Moves.MaxMoves)
                                {
                                    client.Player.GetActiveRecruit().LearnNewMove(move);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Move Given] " + client.Player.Name + " gave themselves the move: " + MoveManager.Moves[move].Name);
                                }
                                Messenger.SendPlayerMoves(client);
                            }
                        }
                        break;
                    case "/give":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Developer))
                            {
                                Client n = ClientManager.FindClient(command[1]);
                                int itemAmount = command[2].ToInt();
                                string item = command[3];
                                if (itemAmount == 0)
                                {
                                    Messenger.PlayerMsg(client, "Invalid item amount.", Text.BrightRed);
                                }
                                else if (n == null)
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                                else
                                {
                                    if (item.IsNumeric())
                                    {
                                        if (item.ToInt() <= 0 || item.ToInt() > Server.Items.ItemManager.Items.MaxItems)
                                        {
                                            Messenger.PlayerMsg(client, "Invalid item number.", Text.BrightRed);
                                        }
                                        else
                                        {
                                            if (ItemManager.Items[item.ToInt()].StackCap <= 1)
                                            {
                                                for (int i = itemAmount; i > 0; i--)
                                                {
                                                    n.Player.GiveItem(item.ToInt(), 1);
                                                }
                                                Messenger.PlayerMsg(client, "You have given " + n.Player.Name + " " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + "!", Text.Yellow);
                                                Messenger.PlayerMsg(n, client.Player.Name + " has given you " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + "!", Text.Yellow);
                                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Item Given] " + client.Player.Name + " gave " + n.Player.Name + " " + itemAmount + " " + ItemManager.Items[item.ToInt()].Name);
                                            }
                                            else
                                            {
                                                n.Player.GiveItem(item.ToInt(), itemAmount);
                                                Messenger.PlayerMsg(client, "You have given " + n.Player.Name + " " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + "!", Text.Yellow);
                                                Messenger.PlayerMsg(n, client.Player.Name + " has given you " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + "!", Text.Yellow);
                                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Item Given] " + client.Player.Name + " gave " + n.Player.Name + " " + itemAmount + " " + ItemManager.Items[item.ToInt()].Name);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        int itemNum = -1;
                                        for (int i = Server.Items.ItemManager.Items.MaxItems; i > 0; i--)
                                        {
                                            if (ItemManager.Items[i].Name.ToLower().StartsWith(item.ToLower()))
                                            {
                                                itemNum = i;
                                            }
                                        }
                                        if (itemNum == -1)
                                        {
                                            Messenger.PlayerMsg(client, "Unable to find an item that starts with " + item, Text.Yellow);
                                        }
                                        else
                                        {
                                            n.Player.GiveItem(itemNum, itemAmount);
                                            Messenger.PlayerMsg(client, "You have given " + n.Player.Name + " " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + "!", Text.Yellow);
                                            Messenger.PlayerMsg(n, client.Player.Name + " has given you " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + "!", Text.Yellow);
                                            Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Item Given] " + client.Player.Name + " gave " + n.Player.Name + " " + itemAmount + " " + ItemManager.Items[item.ToInt()].Name);
                                        }
                                    }
                                }

                            }
                        }
                        break;
                    case "/take":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Developer))
                            {
                                Client n = ClientManager.FindClient(command[1]);
                                int itemAmount = command[2].ToInt();
                                string item = command[3];
                                if (itemAmount == 0)
                                {
                                    Messenger.PlayerMsg(client, "Invalid item amount.", Text.BrightRed);
                                }
                                else if (n == null)
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                                else
                                {
                                    if (item.IsNumeric())
                                    {
                                        if (item.ToInt() <= 0 || item.ToInt() > Server.Items.ItemManager.Items.MaxItems)
                                        {
                                            Messenger.PlayerMsg(client, "Invalid item number.", Text.BrightRed);
                                        }
                                        else
                                        {
                                            n.Player.TakeItem(item.ToInt(), itemAmount);
                                            Messenger.PlayerMsg(client, "You have taken " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + " from " + n.Player.Name + "!", Text.Yellow);
                                            Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Item Taken] " + client.Player.Name + " took " + itemAmount + " " + ItemManager.Items[item.ToInt()].Name + " from " + n.Player.Name);
                                            //NetScript.PlayerMsg(player, NetScript.GetPlayerName(index) + " has given you " +  itemAmount.ToString() + " " + NetScript.GetItemName(item.ToInt()) + "!", Text.Yellow);
                                        }
                                    }
                                    else
                                    {
                                        int itemNum = -1;
                                        for (int i = Server.Items.ItemManager.Items.MaxItems; i > 0; i--)
                                        {
                                            if (ItemManager.Items[i].Name.ToLower().StartsWith(item.ToLower()))
                                            {
                                                itemNum = i;
                                            }
                                        }
                                        if (itemNum == -1)
                                        {
                                            Messenger.PlayerMsg(client, "Unable to find an item that starts with " + item, Text.Yellow);
                                        }
                                        else
                                        {
                                            n.Player.TakeItem(itemNum, itemAmount);
                                            Messenger.PlayerMsg(client, "You have taken " + itemAmount.ToString() + " " + ItemManager.Items[item.ToInt()].Name + " from " + n.Player.Name + "!", Text.Yellow);
                                            Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Item Taken] " + client.Player.Name + " took " + itemAmount + " " + ItemManager.Items[item.ToInt()].Name + " from " + n.Player.Name);
                                            //NetScript.PlayerMsg(player, NetScript.GetPlayerName(index) + " has given you " +  itemAmount.ToString() + " " + NetScript.GetItemName(itemNum) + "!", Text.Yellow);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "/save":
                        {
                            if (client.Player.SavingLocked == false)
                            {
                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    client.Player.SaveCharacterData(dbConnection);
                                }
                                Messenger.PlayerMsg(client, "You have saved the game!", Text.BrightGreen);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You cannot save right now!", Text.BrightRed);
                            }
                        }
                        break;
                    //damageturn ~ obsolete because nothing targets anything anymore
                    case "/s":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying() && i.Player.Access == Enums.Rank.Scripter)
                                    {
                                        Messenger.PlayerMsg(i, client.Player.Name + " [Script Chat]: " + joinedArgs, System.Drawing.Color.MediumSlateBlue);

                                    }
                                }

                            }
                        }
                        break;
                    case "/g":
                        {
                            if (!string.IsNullOrEmpty(client.Player.GuildName) && !string.IsNullOrEmpty(joinedArgs) && client.Player.Muted == false)
                            {
                                OnChatMessageRecieved(client, joinedArgs, Enums.ChatMessageType.Guild);
                                Server.Logging.ChatLogger.AppendToChatLog("Guild Chat/" + client.Player.GuildName, client.Player.Name + ": " + joinedArgs);
                                /*
                                List<System.Drawing.Color> textChoices = new List<System.Drawing.Color>();

                                textChoices.Add(Text.Blue);
                                textChoices.Add(Text.Green);
                                textChoices.Add(Text.Cyan);
                                textChoices.Add(Text.Red);
                                textChoices.Add(Text.Magenta);
                                textChoices.Add(Text.Grey);
                                textChoices.Add(Text.Brown);
                                textChoices.Add(Text.BrightBlue);
                                textChoices.Add(Text.BrightGreen);
                                textChoices.Add(Text.BrightCyan);
                                textChoices.Add(Text.BrightRed);
                                textChoices.Add(Text.Pink);
                                textChoices.Add(Text.Yellow);
                                textChoices.Add(Text.Blue);
                                */
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying() && (Ranks.IsAllowed(i, Enums.Rank.Moniter) || i.Player.GuildName == client.Player.GuildName))
                                    {
                                        Messenger.PlayerMsg(i, client.Player.Name + " [" + client.Player.GuildName + "]: " + joinedArgs, System.Drawing.Color.MediumSpringGreen);

                                    }
                                }

                            }
                        }
                        break;
                    case "/finditemend":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int itemsFound = 0;
                                for (int i = 0; i < Server.Items.ItemManager.Items.MaxItems; i++)
                                {
                                    if (ItemManager.Items[i].Name.ToLower().EndsWith(joinedArgs.ToLower()))
                                    {
                                        Messenger.PlayerMsg(client, ItemManager.Items[i].Name + "'s number is " + i.ToString(), Text.Yellow);
                                        itemsFound++;
                                        //return;
                                    }
                                }
                                if (itemsFound == 0)
                                {
                                    Messenger.PlayerMsg(client, "Unable to find an item that starts with '" + joinedArgs + "'", Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/finditem":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int itemsFound = 0;
                                if (String.IsNullOrEmpty(joinedArgs))
                                {
                                    Messenger.PlayerMsg(client, "Type in an item name.", Text.Yellow);
                                }
                                else
                                {
                                    for (int i = 0; i < Server.Items.ItemManager.Items.MaxItems; i++)
                                    {
                                        if (ItemManager.Items[i].Name.ToLower().Contains(joinedArgs.ToLower()))
                                        {
                                            Messenger.PlayerMsg(client, ItemManager.Items[i].Name + "'s number is " + i.ToString(), Text.Yellow);
                                            itemsFound++;
                                            //return;
                                        }
                                    }
                                    if (itemsFound == 0)
                                    {
                                        Messenger.PlayerMsg(client, "Unable to find an item that starts with '" + joinedArgs + "'", Text.Yellow);
                                    }
                                }
                            }
                        }
                        break;

                    case "/itemcheck":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                for (int i = 810; i <= 810; i++)
                                {

                                    ItemManager.Items[i].Name = "Poké Flute";
                                    Messenger.SendUpdateItemToAll(i);
                                    //ItemManager.SaveItem(i);
                                    Messenger.PlayerMsg(client, i + ": " + ItemManager.Items[i].Name, Text.Yellow);

                                }

                            }
                        }
                        break;
                    case "/itemreq":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                for (int i = 1; i <= 1900; i++)
                                {

                                }

                            }
                        }
                        break;
                    case "/itemdesc":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                for (int i = 612; i <= 628; i++)
                                {
                                    if (ItemManager.Items[i].ScriptedReq == 1)
                                    {
                                        ItemManager.Items[i].Desc = "A treasure for " + (Enums.PokemonType)ItemManager.Items[i].ReqData1 + "-Types.  Give it to a team member to prevent damage from " +
                                            (Enums.PokemonType)ItemManager.Items[i].Data2 + "-type attacks for the team's " + (Enums.PokemonType)ItemManager.Items[i].ReqData1 + "-Type team members.";
                                        Messenger.SendUpdateItemToAll(i);
                                        ItemManager.SaveItem(i);
                                        Messenger.PlayerMsg(client, ItemManager.Items[i].Name, Text.Yellow);
                                    }
                                }
                            }

                        }
                        break;
                    case "/findnpc":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int npcsFound = 0;
                                if (String.IsNullOrEmpty(joinedArgs))
                                {
                                    Messenger.PlayerMsg(client, "Type in an npc name.", Text.Yellow);
                                }
                                else
                                {
                                    for (int i = 1; i <= Server.Npcs.NpcManager.Npcs.MaxNpcs; i++)
                                    {
                                        if (NpcManager.Npcs[i].Name.ToLower().Contains(joinedArgs.ToLower()))
                                        {
                                            Messenger.PlayerMsg(client, NpcManager.Npcs[i].Name + "'s number is " + i.ToString(), Text.Yellow);
                                            npcsFound++;
                                            //return;
                                        }
                                    }
                                    if (npcsFound == 0)
                                    {
                                        Messenger.PlayerMsg(client, "Unable to find an npc that starts with '" + joinedArgs + "'", Text.Yellow);
                                    }
                                }
                            }
                        }
                        break;
                    case "/findnpcuse":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (joinedArgs.IsNumeric())
                                {
                                    int npcNum = joinedArgs.ToInt();
                                    if (npcNum > 0 && npcNum <= Server.Npcs.NpcManager.Npcs.MaxNpcs)
                                    {
                                        int itemsFound = 0;
                                        Messenger.PlayerMsg(client, "NPC# " + npcNum + " (" + NpcManager.Npcs[npcNum].Name + ") is found in RDungeons:", Text.Yellow);
                                        for (int i = 0; i < RDungeonManager.RDungeons.Count; i++)
                                        {
                                            int rangeStart = -1;
                                            for (int j = 0; j < RDungeonManager.RDungeons[i].Floors.Count; j++)
                                            {
                                                bool npcFoundOnFloor = false;
                                                for (int k = 0; k < RDungeonManager.RDungeons[i].Floors[j].Npcs.Count; k++)
                                                {
                                                    //Messenger.PlayerMsg(client, "--" + k.ToString(), Text.Yellow);
                                                    if (RDungeonManager.RDungeons[i].Floors[j].Npcs[k].NpcNum == npcNum)
                                                    {
                                                        itemsFound++;
                                                        npcFoundOnFloor = true;
                                                        break;
                                                    }
                                                }
                                                if (npcFoundOnFloor)
                                                {
                                                    if (rangeStart == -1) rangeStart = j;
                                                }
                                                else
                                                {
                                                    if (rangeStart != -1)
                                                    {
                                                        int rangeEnd = j;
                                                        if (rangeEnd - rangeStart == 1)
                                                        {
                                                            Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1), Text.Yellow);
                                                        }
                                                        else
                                                        {
                                                            Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1) + "-F" + rangeEnd, Text.Yellow);
                                                        }
                                                        rangeStart = -1;
                                                    }
                                                }
                                            }
                                            if (rangeStart != -1)
                                            {
                                                int rangeEnd = RDungeonManager.RDungeons[i].Floors.Count;
                                                if (rangeEnd - rangeStart == 1)
                                                {
                                                    Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1), Text.Yellow);
                                                }
                                                else
                                                {
                                                    Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1) + "-F" + rangeEnd, Text.Yellow);
                                                }
                                                rangeStart = -1;
                                            }
                                        }
                                        if (itemsFound <= 0)
                                        {
                                            Messenger.PlayerMsg(client, "[None]", Text.Yellow);
                                        }
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "Input Out of Range", Text.Yellow);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Input invalid.", Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/finditemuse":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (joinedArgs.IsNumeric())
                                {
                                    int npcNum = joinedArgs.ToInt();
                                    if (npcNum > 0 && npcNum <= Server.Items.ItemManager.Items.MaxItems)
                                    {
                                        int itemsFound = 0;
                                        Messenger.PlayerMsg(client, "Item# " + npcNum + " (" + ItemManager.Items[npcNum].Name + ") is found in RDungeons:", Text.Yellow);
                                        for (int i = 0; i < RDungeonManager.RDungeons.Count; i++)
                                        {
                                            int rangeStart = -1;
                                            for (int j = 0; j < RDungeonManager.RDungeons[i].Floors.Count; j++)
                                            {
                                                bool itemFoundOnFloor = false;
                                                for (int k = 0; k < RDungeonManager.RDungeons[i].Floors[j].Items.Count; k++)
                                                {
                                                    //Messenger.PlayerMsg(client, "--" + k.ToString(), Text.Yellow);
                                                    if (RDungeonManager.RDungeons[i].Floors[j].Items[k].ItemNum == npcNum)
                                                    {
                                                        itemsFound++;
                                                        itemFoundOnFloor = true;
                                                        break;
                                                    }
                                                }
                                                if (itemFoundOnFloor)
                                                {
                                                    if (rangeStart == -1) rangeStart = j;
                                                }
                                                else
                                                {
                                                    if (rangeStart != -1)
                                                    {
                                                        int rangeEnd = j;
                                                        if (rangeEnd - rangeStart == 1)
                                                        {
                                                            Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1), Text.Yellow);
                                                        }
                                                        else
                                                        {
                                                            Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1) + "-F" + rangeEnd, Text.Yellow);
                                                        }
                                                        rangeStart = -1;
                                                    }
                                                }
                                            }
                                            if (rangeStart != -1)
                                            {
                                                int rangeEnd = RDungeonManager.RDungeons[i].Floors.Count;
                                                if (rangeEnd - rangeStart == 1)
                                                {
                                                    Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1), Text.Yellow);
                                                }
                                                else
                                                {
                                                    Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + " F" + (rangeStart + 1) + "-F" + rangeEnd, Text.Yellow);
                                                }
                                                rangeStart = -1;
                                            }
                                        }
                                        if (itemsFound <= 0)
                                        {
                                            Messenger.PlayerMsg(client, "[None]", Text.Yellow);
                                        }
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "Input Out of Range", Text.Yellow);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Input invalid.", Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/finddex":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int npcsFound = 0;
                                for (int i = 1; i <= Constants.TOTAL_POKEMON; i++)
                                {
                                    if (Pokedex.GetPokemon(i).Name.ToLower().Contains(joinedArgs.ToLower()))
                                    {
                                        foreach (PokemonForm form in Pokedex.GetPokemon(i).Forms)
                                        {
                                            Messenger.PlayerMsg(client, Pokedex.GetPokemon(i).Name + "'s dex number is " + i, Text.Yellow);
                                        }
                                        npcsFound++;
                                        //return;
                                    }
                                }
                                if (npcsFound == 0)
                                {
                                    Messenger.PlayerMsg(client, "Unable to find an Pokemon that starts with '" + joinedArgs + "'", Text.Yellow);
                                }
                            }
                        }
                        break;
                    //case "/findmap": {
                    //        //how to check inactive maps?
                    //        if (Ranks.IsAllowed(client, Enums.Rank.Mapper)) {
                    //            int mapsFound = 0;
                    //            if (!string.IsNullOrEmpty(joinedArgs)) {
                    //                for (int i = 1; i <= Server.Settings.MaxMaps; i++) {
                    //                    MapGeneralInfo generalInfo = MapManager.RetrieveMapGeneralInfo(i);
                    //                    if (generalInfo.Name.ToLower().StartsWith(joinedArgs.ToLower())) {
                    //                        Messenger.PlayerMsg(client, generalInfo.Name + "'s number is " + i.ToString(), Text.Yellow);
                    //                        mapsFound++;
                    //                        //return;
                    //                    }
                    //                }
                    //                if (mapsFound == 0) {
                    //                    Messenger.PlayerMsg(client, "Unable to find a map that starts with '" + joinedArgs + "'", Text.Yellow);
                    //                }
                    //            }
                    //        }
                    //    }
                    //    break;
                    case "/findmove":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int movesFound = 0;
                                for (int i = 1; i <= MoveManager.Moves.MaxMoves; i++)
                                {
                                    if (MoveManager.Moves[i].Name.ToLower().Contains(joinedArgs.ToLower()))
                                    {
                                        Messenger.PlayerMsg(client, MoveManager.Moves[i].Name + "'s number is " + i.ToString(), Text.Yellow);
                                        movesFound++;
                                        //return;
                                    }
                                }
                                if (movesFound == 0)
                                {
                                    Messenger.PlayerMsg(client, "Unable to find a move that starts with '" + joinedArgs + "'", Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/findmoverange":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter) && joinedArgs.IsNumeric())
                            {
                                Enums.MoveRange range = (Enums.MoveRange)joinedArgs.ToInt();
                                int movesFound = 0;
                                Messenger.PlayerMsg(client, "Moves with " + range + " range", Text.Yellow);
                                for (int i = 1; i <= MoveManager.Moves.MaxMoves; i++)
                                {
                                    if (MoveManager.Moves[i].RangeType == range && !String.IsNullOrEmpty(MoveManager.Moves[i].Name))
                                    {
                                        Messenger.PlayerMsg(client, "#" + i + ": " + MoveManager.Moves[i].Name, Text.Yellow);
                                        movesFound++;
                                        //return;
                                    }
                                }
                                if (movesFound == 0)
                                {
                                    Messenger.PlayerMsg(client, "[None]", Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/findrdungeon":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int itemsFound = 0;
                                for (int i = 0; i < RDungeonManager.RDungeons.Count; i++)
                                {
                                    if (RDungeonManager.RDungeons[i].DungeonName.ToLower().Contains(joinedArgs.ToLower()))
                                    {
                                        Messenger.PlayerMsg(client, RDungeonManager.RDungeons[i].DungeonName + "'s number is " + (i + 1).ToString(), Text.Yellow);
                                        itemsFound++;
                                        //return;
                                    }
                                }
                                if (itemsFound == 0)
                                {
                                    Messenger.PlayerMsg(client, "Unable to find a random dungeon that starts with '" + joinedArgs + "'", Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/finddungeon":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int itemsFound = 0;
                                for (int i = 1; i < DungeonManager.Dungeons.Count; i++)
                                {
                                    if (DungeonManager.Dungeons[i].Name.ToLower().Contains(joinedArgs.ToLower()))
                                    {
                                        Messenger.PlayerMsg(client, DungeonManager.Dungeons[i].Name + "'s number is " + i.ToString(), Text.Yellow);
                                        itemsFound++;
                                        //return;
                                    }
                                }
                                if (itemsFound == 0)
                                {
                                    Messenger.PlayerMsg(client, "Unable to find a dungeon that starts with '" + joinedArgs + "'", Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/addfriend":
                        {
                            client.Player.AddFriend(joinedArgs);
                        }
                        break;
                    case "/removefriend":
                        {
                            client.Player.RemoveFriend(joinedArgs);
                        }
                        break;
                    //storytile
                    //clearstorytile
                    case "/unlockstory":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                client.Player.SetStoryState(command[1].ToInt() - 1, false);
                                Messenger.PlayerMsg(client, "Chapter " + (command[1].ToInt()) + " has been unlocked!", Text.Yellow);
                            }
                        }
                        break;
                    case "/setstorystate":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                client.Player.SetStoryState(command[1].ToInt() - 1, command[2].ToBool());
                                Messenger.PlayerMsg(client, "Chapter " + (command[1].ToInt()) + " has been set!", Text.Yellow);
                            }
                        }
                        break;
                    case "/resetstats":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    n.Player.Team[0].AtkBonus = 0;
                                    n.Player.Team[0].DefBonus = 0;
                                    n.Player.Team[0].SpclAtkBonus = 0;
                                    n.Player.Team[0].SpclDefBonus = 0;
                                    n.Player.Team[0].SpdBonus = 0;
                                    Messenger.PlayerMsg(client, "Stats have been reset for " + n.Player.Name + "!", Text.Green);
                                    Messenger.PlayerMsg(n, "Your stats have been reset!", Text.Green);
                                }
                            }
                        }
                        break;
                    case "/recruitnum":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, n.Player.GetActiveRecruit().RecruitIndex.ToString(), Text.Green);
                                }
                            }
                        }
                        break;
                    case "/storytest":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.PlayerWarp(client, 500, 7, 9);
                                Messenger.PlayerMsg(client, "Welcome to the story test map!", Text.Yellow);
                            }
                        }
                        break;
                    case "/teststory":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {

                                client.Player.SetStoryState(joinedArgs.ToInt() - 1, false);

                                StoryManager.PlayStory(client, joinedArgs.ToInt() - 1);
                            }
                        }
                        break;
                    case "/teststorybreak":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {

                                Messenger.ForceEndStoryTo(client);
                                client.Player.MovementLocked = false;
                            }
                        }
                        break;

                    case "/findlockedstory":
                        {
                            // TODO: /findlockedstory [What's this do?]
                        }
                        break;
                    //muteadmin
                    case "/mute*":
                    case "/mute":
                        {
                            Client n;
                            string[] subCommand = command[0].Split('*');
                            if (subCommand.Length > 1)
                            {
                                n = ClientManager.FindClient(joinedArgs, true);
                            }
                            else
                            {
                                n = ClientManager.FindClient(joinedArgs);
                            }
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter) && n != null)
                            {
                                n.Player.Muted = true;
                                n.Player.Status = "MUTED";
                                Messenger.PlayerMsg(n, "You have been muted.", Text.Green);
                                Messenger.AdminMsg("[Staff] " + client.Player.Name + " has muted " + n.Player.Name + ".", Text.BrightBlue);
                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Mute Issued] " + client.Player.Name + " muted " + n.Player.Name);

                                PlayerInfoReport(n);

                                Messenger.SendPlayerData(n);
                            }
                        }
                        break;
                    case "/permamute*":
                    case "/permamute":
                        {
                            try
                            {
                                if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                                {
                                    string playerName = command[1];
                                    string muteTimeDays = "-----";
                                    Client bannedClient;

                                    string[] subCommand = command[0].Split('*');

                                    if (subCommand.Length > 1)
                                    {
                                        bannedClient = ClientManager.FindClient(playerName, true);
                                    }
                                    else
                                    {
                                        bannedClient = ClientManager.FindClient(playerName);
                                    }

                                    if (command.CommandArgs.Count > 2 && command[2].IsNumeric())
                                    {
                                        muteTimeDays = DateTime.Now.AddDays(Convert.ToDouble(command[2])).ToString();
                                    }

                                    if (bannedClient != null)
                                    {
                                        bannedClient.Player.Muted = true;
                                        bannedClient.Player.Status = "MUTED";
                                        Messenger.PlayerMsg(bannedClient, "You have been permamuted.", Text.Green);
                                        Messenger.AdminMsg("[Staff] " + client.Player.Name + " has permamuted " + bannedClient.Player.Name + ".", Text.BrightBlue);
                                        Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Permamute Issued] " + client.Player.Name + " muted " + bannedClient.Player.Name);
                                        PlayerInfoReport(bannedClient);
                                        Messenger.SendPlayerData(bannedClient);
                                        using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                        {
                                            Bans.BanPlayer(dbConnection, bannedClient.IP.ToString(), bannedClient.Player.CharID,
                                                bannedClient.Player.AccountName + "/" + bannedClient.Player.Name, bannedClient.MacAddress, bannedClient.BiosId,
                                                client.Player.CharID, client.IP.ToString(), muteTimeDays, Enums.BanType.Mute);
                                        }
                                    }
                                    else
                                    {
                                        using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                        {
                                            IDataColumn[] columns = dbConnection.Database.RetrieveRow("characteristics", "CharID", "Name=\"" + playerName + "\"");
                                            if (columns != null)
                                            {
                                                string charID = (string)columns[0].Value;
                                                string foundIP = (string)dbConnection.Database.RetrieveRow("character_statistics", "LastIPAddressUsed", "CharID=\"" + charID + "\"")[0].Value;
                                                string foundMac = (string)dbConnection.Database.RetrieveRow("character_statistics", "LastMacAddressUsed", "CharID=\"" + charID + "\"")[0].Value;
                                                string storedUUID = (string)dbConnection.Database.RetrieveRow("character_statistics", "StoredUUID", "CharID=\"" + charID + "\"")[0].Value;
                                                //get previous IP and mac
                                                Bans.BanPlayer(dbConnection, foundIP, charID, playerName, foundMac, storedUUID,
                                                    client.Player.CharID, client.IP.ToString(), muteTimeDays, Enums.BanType.Mute);
                                                Messenger.AdminMsg("[Staff] " + client.Player.Name + " has permamuted " + bannedClient.Player.Name + ".", Text.BrightBlue);
                                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Permamute Issued] " + client.Player.Name + " muted " + bannedClient.Player.Name);
                                            }
                                            else
                                            {
                                                Messenger.PlayerMsg(client, "Unable to find player!", Text.BrightRed);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Messenger.AdminMsg("Error: Permamute", Text.White);
                                Messenger.AdminMsg(ex.ToString(), Text.White);
                            }
                        }
                        break;
                    case "/unmute*":
                    case "/unmute":
                        {
                            Client n;
                            string[] subCommand = command[0].Split('*');
                            if (subCommand.Length > 1)
                            {
                                n = ClientManager.FindClient(joinedArgs, true);
                            }
                            else
                            {
                                n = ClientManager.FindClient(joinedArgs);
                            }
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter) && n != null)
                            {
                                n.Player.Muted = false;
                                n.Player.Status = "";
                                Messenger.PlayerMsg(n, "You have been unmuted.", Text.Green);
                                Messenger.AdminMsg("[Staff] " + client.Player.Name + " has unmuted " + n.Player.Name + ".", Text.BrightBlue);
                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Unmute] " + client.Player.Name + " unmuted " + n.Player.Name);
                                Messenger.SendPlayerData(n);
                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    Bans.RemoveBan(dbConnection, "BannedPlayerID", n.Player.CharID);
                                }
                            }
                        }
                        break;
                    case "/kill":
                        {
                            // TODO: /kill [Scripts]
                            Messenger.PlayerMsg(client, "That is (kinda) not a valid command!", Text.BrightRed);
                        }
                        break;
                    case "/jail":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (command.CommandArgs.Count == 2)
                                {
                                    Client n = ClientManager.FindClient(joinedArgs);
                                    if (n != null)
                                    {
                                        if (n != client)
                                        {
                                            string mapID = n.Player.MapID;
                                            if (mapID == MapManager.GenerateMapID(666))
                                            {
                                                Messenger.PlayerMsg(client, "The player is already in jail!", Text.BrightRed);
                                            }
                                            else
                                            {
                                                Messenger.PlayerWarp(n, 666, 10, 12);
                                                Messenger.PlayerMsg(n, "You have been jailed! " + "Please wait for " + client.Player.Name + " or another online staff member to assess the situation.", Text.Yellow);
                                                Messenger.AdminMsg("[Staff] " + n.Player.Name + " has been sent to jail by " + client.Player.Name + "!", Text.BrightBlue);
                                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Jail] " + client.Player.Name + " jailed " + n.Player.Name);
                                            }
                                        }
                                        else
                                        {
                                            Messenger.PlayerMsg(client, "You can't jail yourself!", Text.BrightRed);
                                        }
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                    }
                                }
                            }
                        }
                        break;
                    case "/unjail":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (command.CommandArgs.Count == 2)
                                {
                                    Client n = ClientManager.FindClient(joinedArgs);
                                    if (n != null)
                                    {
                                        if (n != client)
                                        {
                                            string mapID = n.Player.MapID;
                                            if (mapID != MapManager.GenerateMapID(666))
                                            {
                                                Messenger.PlayerMsg(client, "The player is not in jail!", Text.BrightRed);
                                            }
                                            else
                                            {
                                                Messenger.PlayerWarp(n, Crossroads, 25, 25);
                                                Messenger.PlayerMsg(n, "You have been unjailed by " + client.Player.Name + "!", Text.Yellow);
                                                Messenger.AdminMsg("[Staff] " + n.Player.Name + " has been freed from jail by " + client.Player.Name + "!", Text.BrightBlue);
                                                Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Unjail] " + client.Player.Name + " unjailed " + n.Player.Name);
                                            }
                                        }
                                        else
                                        {
                                            Messenger.PlayerMsg(client, "You can't unjail yourself!", Text.BrightRed);
                                        }
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                    }
                                }
                            }
                        }
                        break;
                    //warphere
                    case "/tostartall":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                //if (command[1].IsNumeric()) {
                                List<Client> clientList = new List<Client>();

                                foreach (Client n in client.Player.Map.GetClients())
                                {
                                    clientList.Add(n);
                                }

                                foreach (Client n in clientList)
                                {
                                    Messenger.PlayerWarp(n, 1015, 25, 25);
                                    n.Player.Dead = false;
                                    PacketBuilder.AppendDead(n, hitlist);
                                    Messenger.PlayerMsg(n, "You have been warped to the crossroads by " + client.Player.Name + "!", Text.BrightGreen);
                                    Messenger.PlayerMsg(client, n.Player.Name + " has been warped to the crossroads!", Text.BrightGreen);
                                }

                                //} else {

                                //}

                            }
                        }
                        break;
                    case "/tostart*":
                    case "/tostart":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string playerName = joinedArgs;
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(playerName);
                                }
                                if (n != null)
                                {
                                    Messenger.PlayerWarp(n, 1015, 25, 25);
                                    n.Player.Dead = false;
                                    PacketBuilder.AppendDead(n, hitlist);
                                    Messenger.PlayerMsg(n, "You have been warped to the crossroads by " + client.Player.Name + "!", Text.BrightGreen);
                                    Messenger.PlayerMsg(client, n.Player.Name + " has been warped to the crossroads!", Text.BrightGreen);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Warp Event] " + client.Player.Name + " warped " + n.Player.Name + " to The Crossroads.");
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/world":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.PlayerWarp(client, 538, 10, 17);
                                Messenger.PlayerMsg(client, "Welcome to the World Map!", Text.BrightGreen);
                            }
                        }
                        break;
                    case "/warpto":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                if (command[1].IsNumeric())
                                {

                                    Messenger.PlayerWarp(client, command[1].ToInt(), client.Player.X, client.Player.Y);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Warp Event] " + client.Player.Name + " warped to map " + command[1] + " - " + client.Player.Map.Name);
                                }
                                else
                                {
                                    // TODO: /warpto findmap method [Scripts]
                                    //findmap method

                                }
                            }
                        }
                        break;
                    case "/warpmeto*":
                    case "/warpmeto":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client target;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    target = ClientManager.FindClient(joinedArgs, true);
                                }
                                else
                                {
                                    target = ClientManager.FindClient(joinedArgs);
                                }
                                if (target != null)
                                {
                                    Messenger.PlayerWarp(client, target.Player.GetCurrentMap(), target.Player.X, target.Player.Y);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Warp Event] " + client.Player.Name + " warped to " + target.Player.Name + " on map: " + target.Player.MapID + " - " + target.Player.Map.Name);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player could not be found.", Text.Green);
                                }
                            }
                        }
                        break;
                    case "/warptome*":
                    case "/warptome":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client target;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    target = ClientManager.FindClient(joinedArgs, true);
                                }
                                else
                                {
                                    target = ClientManager.FindClient(joinedArgs);
                                }
                                if (target != null)
                                {
                                    Messenger.PlayerWarp(target, client.Player.GetCurrentMap(), client.Player.X, client.Player.Y);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Warp Event] " + client.Player.Name + " warped " + target.Player.Name + " to them on map:" + client.Player.MapID + " - " + client.Player.Map.Name);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player could not be found.", Text.Green);
                                }
                            }
                        }
                        break;
                    //masswarp
                    case "/help":
                        {
                            //...
                        }
                        break;
                    case "/viewemotes":
                        {
                            //will make the command when we make the emotes
                        }
                        break;
                    case "/map*":
                    case "/map":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string playerName = command[1];
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(playerName);
                                }

                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, n.Player.Name + " is at Map " + n.Player.MapID, Text.Green);
                                    Messenger.PlayerMsg(client, n.Player.Map.Name, Text.Green);
                                    Messenger.PlayerMsg(client, n.Player.X + ", " + n.Player.Y, Text.Green);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Info Request] " + client.Player.Name + " checked " + n.Player.Name + "'s map.");
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, playerName + " could not be found.", Text.Green);
                                }
                            }
                        }
                        break;
                    case "/tcpid":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                string playerName = command[1];
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(playerName);
                                }

                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, n.TcpID.EndPoint.ToString(), Text.Yellow);
                                    Messenger.PlayerMsg(client, ClientManager.GetClient(n.TcpID).Player.Name, Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/playerin":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                //if (command[1].IsNumeric()) {
                                //Messenger.PlayerMsg(client, "Players in this map :", Text.Yellow);
                                //foreach (MapPlayer playerOnMap in client.Player.Map.PlayersOnMap.GetPlayers()) {
                                //    Messenger.PlayerMsg(client, playerOnMap.PlayerID, Text.Yellow);
                                //}
                                int count = 0;
                                foreach (Client i in client.Player.Map.GetClients())
                                {
                                    count++;
                                    //Messenger.PlayerMsg(client, i.Player.Name, Text.Yellow);
                                }
                                Messenger.PlayerMsg(client, "Clients in this map: " + count, Text.Yellow);
                                //foreach (Client i in client.Player.Map.GetClients()) {
                                //Messenger.PlayerMsg(client, i.Player.Name, Text.Yellow);
                                //}

                                //} else {

                                //}

                            }
                        }
                        break;
                    case "/playerindungeon":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (command[1].IsNumeric())
                                {
                                    foreach (Client i in ClientManager.GetClients())
                                    {
                                        if (i.IsPlaying() && i.Player.Map.MapType == Enums.MapType.RDungeonMap
                                            && ((RDungeonMap)i.Player.Map).RDungeonIndex == command[1].ToInt() - 1)
                                        {
                                            Messenger.PlayerMsg(client, i.Player.Name + " is on Floor " + (((RDungeonMap)i.Player.Map).RDungeonFloor + 1), Text.BrightCyan);
                                        }
                                    }
                                }
                                else
                                {

                                }
                            }
                        }
                        break;
                    case "/playerintc":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {

                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying() && i.Player.Map.MapType == Enums.MapType.RDungeonMap
                                        && ((RDungeonMap)i.Player.Map).RDungeonIndex >= 70 && ((RDungeonMap)i.Player.Map).RDungeonIndex <= 86)
                                    {
                                        Messenger.PlayerMsg(client, i.Player.Name + " is on #" + (((RDungeonMap)i.Player.Map).RDungeonIndex + 1), Text.BrightCyan);
                                        Messenger.PlayerMsg(client, "-Floor " + (((RDungeonMap)i.Player.Map).RDungeonFloor + 1), Text.Yellow);
                                    }
                                }

                            }
                        }
                        break;
                    case "/playerindungeons":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int total = 0;
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying() && i.Player.Map.Moral == Enums.MapMoral.None)
                                    {

                                        Messenger.PlayerMsg(client, i.Player.Name + " is at " + i.Player.Map.Name, Text.BrightCyan);
                                        total++;
                                    }
                                }
                                Messenger.PlayerMsg(client, "Total: " + total, Text.BrightCyan);

                            }
                        }
                        break;
                    case "/hp":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s HP: " + n.Player.GetActiveRecruit().HP.ToString(), Text.Yellow);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/playerid":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {

                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s ID: " + n.Player.CharID, Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "/forceswap":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {

                                Client n = ClientManager.FindClient(command[1]);
                                if (n != null)
                                {
                                    int slot = 0;
                                    //for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                                    if (n.Player.Team[command[2].ToInt()] != null && n.Player.Team[command[2].ToInt()].Loaded)
                                    {
                                        slot = command[2].ToInt();
                                    }
                                    //}
                                    n.Player.SwapActiveRecruit(slot);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/info*":
                    case "/info":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(joinedArgs, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(joinedArgs);
                                }

                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, "Account: " + n.Player.AccountName + ", Name: " + n.Player.Name, Text.Yellow);
                                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++)
                                    {
                                        if (n.Player.Team[i] != null && n.Player.Team[i].Loaded)
                                        {
                                            Messenger.PlayerMsg(client, "Team #" + i + ": " + Pokedex.GetPokemon(n.Player.Team[i].Species).Name + " Lv." + n.Player.Team[i].Level, Text.Yellow);
                                            Messenger.PlayerMsg(client, "HP: " + n.Player.Team[i].HP + "/" + n.Player.Team[i].MaxHP, Text.Yellow);
                                            Messenger.PlayerMsg(client, "Exp: " + n.Player.Team[i].Exp + "/" + n.Player.Team[i].GetNextLevel(), Text.Yellow);
                                            Messenger.PlayerMsg(client, "Atk/Sp.Atk: " + n.Player.Team[i].Atk + "/" + n.Player.Team[i].SpclAtk, Text.Yellow);
                                            Messenger.PlayerMsg(client, "Def/Sp.Def: " + n.Player.Team[i].Def + "/" + n.Player.Team[i].SpclDef, Text.Yellow);
                                            Messenger.PlayerMsg(client, "Speed: " + n.Player.Team[i].Spd, Text.Yellow);
                                        }
                                    }
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Info Request] " + client.Player.Name + " checked " + n.Player.Name + "'s team information.");
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/statusinfo":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {

                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {

                                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++)
                                    {
                                        if (n.Player.Team[i] != null && n.Player.Team[i].Loaded)
                                        {
                                            Messenger.PlayerMsg(client, "Team #" + i + ": " + Pokedex.GetPokemon(n.Player.Team[i].Species).Name + "/" + n.Player.Team[i].StatusAilment, Text.Yellow);
                                            for (int j = 0; j < n.Player.Team[i].VolatileStatus.Count; j++)
                                            {
                                                Messenger.PlayerMsg(client, n.Player.Team[i].VolatileStatus[j].Name +
                                                    "/" + n.Player.Team[i].VolatileStatus[j].Counter + "/" + n.Player.Team[i].VolatileStatus[j].Tag, Text.Yellow);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/getip*":
                    case "/getip":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {

                                string playerName = command[1];
                                Client n;
                                string[] subCommand = command[0].Split('*');
                                if (subCommand.Length > 1)
                                {
                                    n = ClientManager.FindClient(playerName, true);
                                }
                                else
                                {
                                    n = ClientManager.FindClient(playerName);
                                }

                                if (n != null)
                                {
                                    if (Ranks.IsAllowed(n, Enums.Rank.ServerHost))
                                    {
                                        Messenger.PlayerMsg(client, n.Player.Name + "'s IP: 46.4.166.141", Text.Yellow);
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, n.Player.Name + "'s IP: " + n.IP.ToString(), Text.Yellow);
                                    }
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s MAC: " + n.MacAddress, Text.Yellow);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Info Request] " + client.Player.Name + " checked " + n.Player.Name + "'s IP/MAC.");

                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/findip":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.PlayerMsg(client, "Searching for players with the IP: \"" + joinedArgs + "\"", Text.BrightBlue);
                                foreach (Client n in ClientManager.GetClients())
                                {
                                    if (n.IsPlaying())
                                    {
                                        if (n.IP.ToString().StartsWith(joinedArgs))
                                        {
                                            Messenger.PlayerMsg(client, n.Player.AccountName + "/" + n.Player.Name + ": " + n.IP.ToString(), Text.BrightGreen);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    //getindex; no indexes
                    //poke, hug, praise, yawn, wave
                    case "/praise":
                        {
                            if (client.Player.Muted == false)
                            {
                                Messenger.MapMsg(client.Player.MapID, client.Player.Name + " gave praise to " + joinedArgs + "!", Text.Green);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/hug":
                        {
                            if (client.Player.Muted == false)
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    Messenger.MapMsg(client.Player.MapID, client.Player.Name + " has hugged " + command[1] + "!", Text.White);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You have to pick somebody to hug!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;

                    case "/notepad":
                        {
                            if (client.Player.Muted == false)
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    if (command[1].ToLower() != "artmax")
                                    {
                                        Messenger.MapMsg(client.Player.MapID, client.Player.Name + " threw a notepad at " + command[1] + "!", Text.Yellow);
                                    }
                                    else
                                    {
                                        Messenger.MapMsg(client.Player.MapID, client.Player.Name + " threw a notepad at " + command[1] + " (nuclear strike!)", Text.Yellow);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You have to pick somebody to throw a notepad at!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/time":
                        {
                            Messenger.PlayerMsg(client, "It is currently: " + Server.Globals.ServerTime, Text.BrightGreen);
                        }
                        break;

                    case "/me":
                        {
                            if (client.Player.Muted == false)
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    Messenger.MapMsg(client.Player.MapID, client.Player.Name + " " + joinedArgs, Text.BrightBlue);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You have to include something to say besides your name!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;

                    case "/poke":
                        {
                            if (client.Player.Muted == false)
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    Messenger.MapMsg(client.Player.MapID, client.Player.Name + " poked " + command[1] + ".", Text.Yellow);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You have to pick somebody to poke!", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/yawn":
                        {
                            if (client.Player.Muted == false)
                            {
                                Messenger.MapMsg(client.Player.MapID, client.Player.Name + " let out a loud yawn " + joinedArgs + "~", Text.BrightBlue);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/wave":
                        {
                            if (client.Player.Muted == false)
                            {
                                Messenger.MapMsg(client.Player.MapID, client.Player.Name + " waved at " + joinedArgs + ".", Text.BrightGreen);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/away":
                        {
                            if (client.Player.Muted == true)
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                            else if (client.Player.MapID == "s791" || client.Player.MapID == "s792")
                            {
                                Messenger.PlayerMsg(client, "You cannot be away while playing Capture The Flag!", Text.BrightRed);
                            }
                            else if (client.Player.Status.ToLower() == "away")
                            {
                                client.Player.Status = "";
                                Messenger.GlobalMsg(client.Player.Name + " has returned from being away.", Text.Yellow);
                                Messenger.SendPlayerData(client);
                            }
                            else
                            {
                                client.Player.Status = "Away";
                                Messenger.GlobalMsg(client.Player.Name + " is now away.", Text.Yellow);
                                Messenger.SendPlayerData(client);
                            }
                        }
                        break;
                    case "/wb*":
                    case "/wb":
                        {
                            if (client.Player.Muted == false)
                            {
                                if (command.CommandArgs.Count >= 2)
                                {
                                    Client n;
                                    string[] subCommand = command[0].Split('*');
                                    if (subCommand.Length > 1)
                                    {
                                        n = ClientManager.FindClient(joinedArgs, true);
                                    }
                                    else
                                    {
                                        n = ClientManager.FindClient(joinedArgs);
                                    }
                                    if (n != null)
                                    {
                                        Messenger.MapMsg(client.Player.MapID, client.Player.Name + " welcomes " + n.Player.Name + " back to " + Settings.GameNameShort + "!", Text.White);
                                    }
                                    else if (n == null)
                                    {
                                        Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Pick someone to welcome back.", Text.Black);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/pichu!":
                        {
                            if (client.Player.Muted == false)
                            {
                                if (client.Player.GetActiveRecruit().Species == 172)
                                {
                                    Messenger.PlaySoundToMap(client.Player.MapID, "Pichu!.wav");
                                }
                            }
                        }
                        break;
                    case "/muwaha":
                        {
                            if (client.Player.Muted == false)
                            {
                                Messenger.PlaySoundToMap(client.Player.MapID, "magic1268.wav");
                            }
                        }
                        break;
                    case "/status":
                        {
                            if (client.Player.Muted == true)
                            {
                                Messenger.PlayerMsg(client, "You have been muted!", Text.BrightRed);
                            }
                            else if (exPlayer.Get(client).InCTF == false && exPlayer.Get(client).InSnowballGame == false
                                       && joinedArgs != "MUTED")
                            {
                                if (!string.IsNullOrEmpty(joinedArgs))
                                {
                                    string status = joinedArgs;
                                    if (joinedArgs.Length > 10)
                                    {
                                        status = joinedArgs.Substring(0, 10);
                                    }
                                    client.Player.Status = status;
                                    Messenger.SendPlayerData(client);
                                }
                                else
                                {
                                    client.Player.Status = "";
                                    Messenger.SendPlayerData(client);
                                }
                            }
                        }
                        break;
                    case "/giveup":
                        {
                            GiveUp(client);
                        }
                        break;
                    case "/watch":
                        {
                            if (client.Player.MapID == MapManager.GenerateMapID(660) || client.Player.MapID == MapManager.GenerateMapID(1718))
                            {
                                TcpPacket packet = new TcpPacket("focusonpoint");
                                packet.AppendParameters(15, 15);
                                Messenger.SendDataTo(client, packet);
                                client.Player.MovementLocked = true;
                            }
                        }
                        break;

                    case "/stopwatch":
                        {
                            if (client.Player.MapID == MapManager.GenerateMapID(660) || client.Player.MapID == MapManager.GenerateMapID(1718))
                            {
                                TcpPacket packet = new TcpPacket("focusonpoint");
                                packet.AppendParameters(-1, -1);
                                Messenger.SendDataTo(client, packet);
                                client.Player.MovementLocked = false;
                            }
                        }
                        break;
                    case "/sethouse":
                        {
                            if (exPlayer.Get(client).IsValidPlayerSpawn(client.Player.MapID) == true
                                && client.Player.Map.Tile[client.Player.X, client.Player.Y].Type != Enums.TileType.Blocked)
                            {
                                exPlayer.Get(client).SpawnMap = client.Player.MapID;
                                exPlayer.Get(client).SpawnX = client.Player.X;
                                exPlayer.Get(client).SpawnY = client.Player.Y;
                                Messenger.PlayerMsg(client, "Spawn point saved!", Text.Yellow);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "This is not a valid spawn point!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/rstart":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (command[1].IsNumeric())
                                {
                                    int floor = 1;
                                    if (command.CommandArgs.Count > 2 && command[2].IsNumeric())
                                    {
                                        floor = command[2].ToInt();
                                    }
                                    //RDungeonManager.LoadRDungeon(command[1].ToInt() - 1);
                                    client.Player.WarpToRDungeon(command[1].ToInt() - 1, floor - 1);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[RDungeon Warp] " + client.Player.Name + " warped to " + RDungeonManager.RDungeons[command[1].ToInt() - 1].DungeonName + ", Floor: " + floor);

                                }
                            }
                        }
                        break;

                    case "/findstory":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                int storiesFound = 0;
                                if (String.IsNullOrEmpty(joinedArgs))
                                {
                                    Messenger.PlayerMsg(client, "This is not the story you are looking for. (Because you didn't specify anything!)", Text.Yellow);
                                }
                                else
                                {
                                    for (int i = 0; i < Server.Stories.StoryManagerBase.Stories.MaxStories; i++)
                                    {
                                        if (StoryManagerBase.Stories[i].Name.ToLower().Contains(joinedArgs.ToLower()))
                                        {
                                            Messenger.PlayerMsg(client, StoryManagerBase.Stories[i].Name + "'s number is " + i.ToString(), Text.Yellow);
                                            storiesFound++;
                                            //return;
                                        }
                                    }
                                    if (storiesFound == 0)
                                    {
                                        Messenger.PlayerMsg(client, "Unable to find a story that starts with '" + joinedArgs + "'", Text.Yellow);
                                    }
                                }
                            }

                        }
                        break;
                    case "/nextfloor":
                        {
                            try
                            {
                                if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                                {
                                    if (client.Player.Map.MapType == Enums.MapType.RDungeonMap && ((RDungeonMap)client.Player.Map).RDungeonIndex > -1)
                                    {
                                        client.Player.WarpToRDungeon(((RDungeonMap)client.Player.Map).RDungeonIndex, ((RDungeonMap)client.Player.Map).RDungeonFloor + 1);
                                    }

                                }
                            }
                            catch (Exception ex)
                            {
                                Messenger.AdminMsg("nextfloor error", Text.Pink);
                                Messenger.AdminMsg(ex.ToString(), Text.Pink);
                            }
                        }
                        break;
                    case "/confuse":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                AddExtraStatus(client.Player.GetActiveRecruit(), client.Player.Map, "Confusion", 5, null, "", hitlist);
                                //Confuse(client.Player.GetActiveRecruit(), client.Player.Map, 5, null);
                            }
                        }
                        break;
                    case "/hittime":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                client.Player.GetActiveRecruit().TimeMultiplier = 500;
                                PacketBuilder.AppendTimeMultiplier(client, hitlist);
                            }
                        }
                        break;
                    case "/visible":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                PacketBuilder.AppendVisibility(client, hitlist, false);
                            }
                        }
                        break;
                    case "/infoexp":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                Messenger.PlayerMsg(client, client.Player.ExplorerRank.ToString(), Text.BrightRed);
                            }
                        }
                        break;
                    case "/testexp":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                client.Player.MissionExp += command[1].ToInt();
                                MissionManager.ExplorerRankUp(client);
                            }
                        }
                        break;
                    case "/fixrank":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    n.Player.ExplorerRank = Enums.ExplorerRank.Normal;
                                    MissionManager.ExplorerRankUp(n);
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s rank is fixed now!", Text.Yellow);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/;":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic675.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 9, 1, 2, hitlist);
                        }
                        break;
                    case "/'":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic664.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 6, 2, 1, hitlist);
                        }
                        break;
                    case "/*":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic678.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 5, 2, 1, hitlist);
                        }
                        break;
                    case "/)":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            PacketBuilder.AppendEmote(client, 7, 2, 1, hitlist);
                        }
                        break;
                    case "/))":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic721.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 7, 2, 7, hitlist);
                        }
                        break;
                    case "/)))":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic657.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 7, 2, 8, hitlist);
                        }
                        break;
                    case "/.":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic700.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 12, 2, 1, hitlist);
                        }
                        break;
                    case "/..":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic700.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 12, 2, 2, hitlist);
                        }
                        break;
                    case "/...":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic700.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 12, 2, 3, hitlist);
                        }
                        break;
                    case "/!":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic667.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 13, 2, 1, hitlist);
                        }
                        break;
                    case "/?":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic665.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 8, 2, 1, hitlist);
                        }
                        break;
                    case "/!?":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic671.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 11, 2, 1, hitlist);
                        }
                        break;
                    case "/+":
                        {
                            if (client.Player.Muted)
                            {
                                Messenger.PlayerMsg(client, "You are muted!", Text.BrightRed);
                                return;
                            }
                            hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("Magic674.wav"), client.Player.X, client.Player.Y, 10);
                            PacketBuilder.AppendEmote(client, 10, 2, 1, hitlist);
                        }
                        break;
                    case "/testailment":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (command[1].IsNumeric() && command[1].ToInt() >= 0 && command[1].ToInt() < 6)
                                {

                                    SetStatusAilment(client.Player.GetActiveRecruit(), client.Player.Map, (Enums.StatusAilment)(command[1].ToInt()), 1, null);
                                    //    for (int i = 0; i < Constants.MAX_MAP_NPCS; i++)
                                    //    {
                                    //        if (client.Player.Map.ActiveNpc[i].Num > 0)
                                    //        {
                                    //            client.Player.Map.ActiveNpc[i].ChangeStatusAilment((Enums.StatusAilment)(command[1].ToInt()), 1);
                                    //        }
                                    //    }
                                }
                            }
                        }
                        break;
                    case "/addvstatus":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                if (command[1].IsNumeric())
                                {
                                    ExtraStatus status = new ExtraStatus();
                                    status.Name = client.Player.GetActiveRecruit().VolatileStatus.Count.ToString();
                                    status.Emoticon = command[1].ToInt();
                                    client.Player.GetActiveRecruit().VolatileStatus.Add(status);
                                    PacketBuilder.AppendVolatileStatus(client, hitlist);

                                    IMap clientMap = client.Player.Map;
                                    for (int i = 0; i < Constants.MAX_MAP_NPCS; i++)
                                    {
                                        if (clientMap.ActiveNpc[i].Num > 0)
                                        {
                                            clientMap.ActiveNpc[i].VolatileStatus.Add(status);
                                            PacketBuilder.AppendNpcVolatileStatus(MapManager.RetrieveActiveMap(clientMap.ActiveNpc[i].MapID), hitlist, i);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "/removevstatus":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                client.Player.GetActiveRecruit().VolatileStatus.Clear();
                                PacketBuilder.AppendVolatileStatus(client, hitlist);

                                IMap clientMap = client.Player.Map;
                                for (int i = 0; i < Constants.MAX_MAP_NPCS; i++)
                                {
                                    if (clientMap.ActiveNpc[i].Num > 0)
                                    {
                                        clientMap.ActiveNpc[i].VolatileStatus.Clear();
                                        PacketBuilder.AppendNpcVolatileStatus(MapManager.RetrieveActiveMap(clientMap.ActiveNpc[i].MapID), hitlist, i);
                                    }
                                }
                            }
                        }
                        break;
                    /*case "/diagonal": {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter)) {
                                IMap clientMap = client.Player.Map;
                                for (int i = 0; i < Constants.MAX_MAP_NPCS; i++) {
                                    if (clientMap.ActiveNpc[i].Num > 0) {
                                        clientMap.ActiveNpc[i].X += 3;
                                        clientMap.ActiveNpc[i].Y += 3;
                                        PacketBuilder.AppendNpcXY(MapManager.RetrieveActiveMap(clientMap.ActiveNpc[i].MapID), hitlist, i);
                                    }
                                }
                            }
                        }
                        break;*/
                    case "/checkailment":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.PlayerMsg(client, client.Player.GetActiveRecruit().StatusAilment.ToString() + client.Player.GetActiveRecruit().StatusAilmentCounter.ToString(), Text.BrightRed);
                            }
                        }
                        break;
                    case "/checkdungeons":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(joinedArgs);
                                if (n != null)
                                {
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s completed dungeons:", Text.Yellow);
                                    for (int i = 0; i < Server.Dungeons.DungeonManager.Dungeons.Count; i++)
                                    {
                                        Messenger.PlayerMsg(client, Server.Dungeons.DungeonManager.Dungeons[i].Name + ": " + n.Player.GetDungeonCompletionCount(i), Text.Yellow);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/testegg":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {

                            }
                        }
                        break;
                    case "/speedlimit":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                if (command[1].IsNumeric() && command[1].ToInt() >= 0 && command[1].ToInt() < 7)
                                {

                                    client.Player.GetActiveRecruit().SpeedLimit = (Enums.Speed)(command[1].ToInt());
                                    PacketBuilder.AppendSpeedLimit(client, hitlist);
                                }
                            }
                        }
                        break;
                    case "/testdeath":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                client.Player.Hunted = false;
                                PacketBuilder.AppendHunted(client, hitlist);
                                client.Player.Dead = true;
                                PacketBuilder.AppendDead(client, hitlist);

                                AskAfterDeathQuestion(client);
                            }
                        }
                        break;
                    case "/mobile":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                if (command[1].IsNumeric())
                                {
                                    client.Player.GetActiveRecruit().Mobility[command[1].ToInt()] = true;
                                    PacketBuilder.AppendMobility(client, hitlist);
                                }
                            }
                        }
                        break;
                    case "/immobile":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                if (command[1].IsNumeric())
                                {
                                    client.Player.GetActiveRecruit().Mobility[command[1].ToInt()] = false;
                                    PacketBuilder.AppendMobility(client, hitlist);
                                }
                            }
                        }
                        break;
                    case "/createparty":
                        {
                            PartyManager.CreateNewParty(client);
                        }
                        break;
                    case "/joinparty":
                        {
                            if (client.Player.PartyID == null)
                            {
                                Party party = PartyManager.FindPlayerParty(ClientManager.FindClient(joinedArgs));
                                PartyManager.JoinParty(party, client);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You are already in a party!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/leaveparty":
                        {
                            if (client.Player.PartyID != null)
                            {
                                if (client.Player.Map.Moral == Enums.MapMoral.None)
                                {
                                    Messenger.PlayerMsg(client, "You can't leave the party here!", Text.BrightRed);
                                }
                                else
                                {
                                    Party party = PartyManager.FindPlayerParty(client);
                                    PartyManager.RemoveFromParty(party, client);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You are not in a party!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/myparty":
                        {
                            if (client.Player.PartyID != null)
                            {
                                Party party = PartyManager.FindPlayerParty(client);
                                Messenger.PlayerMsg(client, "Players in your party:", Text.Black);
                                foreach (Client i in party.GetOnlineMemberClients())
                                {
                                    Messenger.PlayerMsg(client, i.Player.Name, Text.White);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You are not in a party!", Text.BrightRed);
                            }
                        }
                        break;
                    case "/kickparty":
                        {
                            try
                            {
                                if (client.Player.PartyID != null)
                                {
                                    Client targetPlayer = ClientManager.FindClient(command[1]);
                                    if (targetPlayer.Player.PartyID == client.Player.PartyID)
                                    {

                                        Party party = PartyManager.FindPlayerParty(client);
                                        if (party.GetLeader() == client)
                                        {
                                            Client n = ClientManager.FindClient(joinedArgs);
                                            if (n != null)
                                            {
                                                if (n.Player.Map.Moral == Enums.MapMoral.None)
                                                {
                                                    Messenger.PlayerMsg(client, "The party member can't be kicked there!", Text.BrightRed);
                                                }
                                                else
                                                {
                                                    PartyManager.RemoveFromParty(party, n);
                                                }
                                            }
                                            else
                                            {
                                                Messenger.PlayerMsg(client, "Unable to find player.", Text.BrightRed);
                                            }
                                        }
                                        else
                                        {
                                            Messenger.PlayerMsg(client, "You are not the party leader!", Text.BrightRed);
                                        }
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "Player is not in your party!", Text.BrightRed);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You are not in a party!", Text.BrightRed);
                                }
                            }
                            catch (Exception ex)
                            {
                                Messenger.AdminMsg(ex.ToString(), Text.White);
                            }
                        }
                        break;
                    case "/moduleswitch":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                client.Player.SetActiveExpKitModule(Enums.ExpKitModules.Counter);
                            }
                        }
                        break;
                    case "/sticky":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                if (command[1].IsNumeric())
                                {
                                    client.Player.SetItemSticky(command[1].ToInt(), true);
                                }
                            }
                        }
                        break;
                    case "/thticky":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {
                                if (command[1].IsNumeric())
                                {
                                    client.Player.SetItemSticky(command[1].ToInt(), false);
                                }
                            }
                        }
                        break;
                    case "/trade":
                        {
                            Client n = ClientManager.FindClient(joinedArgs);
                            if (n != null)
                            {
                                if (n.Player.MapID == client.Player.MapID)
                                {
                                    client.Player.RequestTrade(n);
                                    Messenger.PlayerMsg(client, "You have asked " + n.Player.Name + " to trade with you!", Text.BrightGreen);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                            }
                        }
                        break;
                    case "/editemoticon":
                    case "/editemotions":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("emoticoneditor"));
                            }
                        }
                        break;
                    case "/edititem":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                if (command[1].IsNumeric())
                                {
                                    int n = command[1].ToInt();

                                    // Prevent hacking
                                    if (n < 0 | n > Server.Items.ItemManager.Items.MaxItems)
                                    {
                                        Messenger.HackingAttempt(client, "Invalid Item Index");
                                        return;
                                    }

                                    Messenger.SendEditItemTo(client, n);
                                }

                            }
                        }
                        break;
                    case "/edititems":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendItemEditor(client);
                            }
                        }
                        break;
                    case "/editmove":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                if (command[1].IsNumeric())
                                {
                                    int n = command[1].ToInt(-1);

                                    // Prevent hacking
                                    if (n < 0 | n > MoveManager.Moves.MaxMoves)
                                    {
                                        Messenger.HackingAttempt(client, "Invalid Move Index");
                                        return;
                                    }

                                    Messenger.SendEditMoveTo(client, n);
                                }

                            }
                        }
                        break;
                    case "/editmoves":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("moveeditor"));
                            }
                        }
                        break;
                    case "/editdungeon":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                if (command[1].IsNumeric())
                                {
                                    if (command[1].ToInt() < 0 && command[1].ToInt() >= DungeonManager.Dungeons.Count)
                                    {
                                        Server.Network.Messenger.HackingAttempt(client, "Invalid Dungeon Number");
                                    }
                                    Messenger.SendEditDungeonTo(client, command[1].ToInt());
                                }
                            }
                        }
                        break;
                    case "/editdungeons":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("dungeoneditor"));
                            }
                        }
                        break;
                    case "/editnpc":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                if (command[1].IsNumeric())
                                {
                                    int n = command[1].ToInt();

                                    // Prevent hacking
                                    /*if (n < 0 || n > Server.Npcs.NpcManager.Npcs.MaxNpcs) {
                                        Messenger.HackingAttempt(client, "Invalid Npc Index");
                                        return;
                                    }*/
                                    Messenger.SendNpcAiTypes(client);
                                    Messenger.SendEditNpcTo(client, n);
                                }

                            }
                        }
                        break;
                    case "/editnpcs":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("npceditor"));
                            }
                        }
                        break;
                    case "/editrdungeon":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                if (command[1].IsNumeric())
                                {
                                    int n = command[1].ToInt();
                                    if (n < 0 || n > RDungeonManager.RDungeons.Count - 1)
                                    {
                                        Messenger.PlayerMsg(client, "Invalid dungeon client", Text.BrightRed);
                                        return;
                                    }

                                    Messenger.SendEditRDungeonTo(client, n);
                                }

                            }
                        }
                        break;
                    case "/editrdungeons":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("rdungeoneditor"));
                            }
                        }
                        break;
                    case "/editstory":
                    case "/editstories":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("storyeditor"));
                            }
                        }
                        break;
                    case "/mapreport":
                        {
                            // Prevent hacking
                            //if (Ranks.IsDisallowed(client, Enums.Rank.Mapper)) {
                            //Messenger.HackingAttempt(client, "Admin Cloning");
                            //return;
                            //}
                            // TODO: Fix MapReport to work with on-demand map loading system
                            //TcpPacket packet = new TcpPacket("mapreport");
                            //for (int i = 1; i <= Server.Settings.MaxMaps; i++) {
                            //packet.AppendParameter(MapManager.Maps[i].Name);
                            //packet.AppendParameter("-Not Implemented-");
                            //}

                            //Messenger.SendDataTo(client, packet);
                        }
                        break;
                    case "/editevolutions":
                    case "/editevolution":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("evolutioneditor"));
                            }
                        }
                        break;
                    case "/editshop":
                    case "/editshops":
                        {
                            // Prevent Hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Server.Network.Messenger.HackingAttempt(client, "Admin Cloning");
                            }
                            else
                            {
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("shopeditor"));
                            }
                        }
                        break;
                    case "/testrecall":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Developer))
                            {
                                Messenger.SendRecallMenu(client, false);
                            }

                        }
                        break;
                    case "/test":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                Debug.RunTest(client);
                            }
                        }
                        break;
                    case "/setform":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                client.Player.GetActiveRecruit().SetForm(command[1].ToInt());
                                Messenger.SendPlayerData(client);
                                Messenger.SendActiveTeam(client);
                                Messenger.SendStats(client);
                            }
                        }
                        break;
                    case "/setgender":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(command[1]);
                                if (n != null)
                                {
                                    n.Player.GetActiveRecruit().Sex = (Enums.Sex)command[2].ToInt();
                                    RefreshCharacterTraits(n.Player.GetActiveRecruit(), n.Player.Map, hitlist);
                                    Messenger.SendPlayerData(n);
                                    Messenger.SendActiveTeam(n);
                                    Messenger.SendStats(n);
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s " + n.Player.GetActiveRecruit().Name + "'s gender was set to " + ((Enums.Sex)command[2].ToInt()).ToString(), Text.Pink);
                                    Server.Logging.ChatLogger.AppendToChatLog("Staff", "[Characteristics] " + client.Player.Name + " changed the gender of " + n.Player.Name + "'s " + n.Player.GetActiveRecruit().Name + " to " + ((Enums.Sex)command[2].ToInt()).ToString());
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/offlinetostart":
                        {
                            try
                            {
                                if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                                {
                                    using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                    {
                                        dbConnection.Database.ExecuteNonQuery("UPDATE mdx_players.location " +
                                            "JOIN mdx_players.characteristics ON mdx_players.characteristics.CharID = mdx_players.location.CharID " +
                                            "SET mdx_players.location.Map = \'s1015\' " +
                                            "WHERE characteristics.Name = \'" + command[1] + "\';");
                                        Messenger.PlayerMsg(client, "Character has been offline-warped to the crossroads", Text.Yellow);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Messenger.PlayerMsg(client, ex.ToString(), Text.Black);
                            }
                        }
                        break;
                    case "/fixhouse":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Client n = ClientManager.FindClient(command[1]);
                                if (n != null)
                                {
                                    string houseID = MapManager.GenerateHouseID(n.Player.CharID, 0);
                                    // Make an empty house
                                    DataManager.Maps.HouseMap rawHouse = new DataManager.Maps.HouseMap(houseID);
                                    rawHouse.Owner = n.Player.CharID;
                                    rawHouse.Room = 0;
                                    IMap map = new House(rawHouse);
                                    map.Moral = Enums.MapMoral.House;
                                    map.Name = n.Player.Name + "'s House";
                                    map.Save();
                                    Messenger.PlayerMsg(client, n.Player.Name + "'s house is cleared.", Text.Pink);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "/addmaps":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Admin))
                            {

                                for (int i = 2002; i <= 3000; i++)
                                {
                                    // Make an empty house
                                    DataManager.Maps.Map rawMap = new DataManager.Maps.Map("s" + i);
                                    Server.Maps.Map map = new Server.Maps.Map(rawMap);
                                    map.Save();
                                    Messenger.PlayerMsg(client, "Map " + i + " added.", Text.Pink);
                                }
                                Messenger.PlayerMsg(client, "Maps added.", Text.Pink);
                            }
                        }
                        break;
                    case "/copycharacter":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                //try {
                                //    using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                                //
                                //        PlayerDataManager.CopyCharacter(dbConnection.Database, command[1], command[2]);
                                //        Messenger.PlayerMsg(client, "Character copied from " + command[1] + " to " + command[2], Text.Black);
                                //    }
                                //} catch (Exception ex) {
                                //    Messenger.PlayerMsg(client, ex.ToString(), Text.Black);
                                //}
                            }

                        }
                        break;
                    case "/addnpcs":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Scripter))
                            {
                                for (int i = 2002; i <= 3000; i++)
                                {
                                    NpcManager.SaveNpc(i);
                                    Messenger.PlayerMsg(client, "NPC " + i + " added.", Text.BrightGreen);
                                }
                            }
                        }
                        break;
                    default:
                        {
                            Messenger.PlayerMsg(client, "That is not a valid command.", Text.BrightRed);
                        }
                        break;
                }

                PacketHitList.MethodEnded(ref hitlist);
            }
            catch (Exception ex)
            {
                Messenger.AdminMsg("Error: Command (" + command.CommandArgs[0] + ")", Text.Black);
                //Messenger.AdminMsg(ex.ToString(), Text.Black);
            }
        }
Beispiel #12
0
        public static void LoadStory(int storyNum, PMDCP.DatabaseConnector.MySql.MySql database)
        {
            if (stories.Stories.ContainsKey(storyNum) == false)
            {
                stories.Stories.Add(storyNum, new Story(storyNum.ToString()));
            }
            Story story = new Story(storyNum.ToString());

            string query = "SELECT revision, " +
                           "name, " +
                           "story_start, " +
                           "is_sandboxed, " +
                           "zone_id " +
                           "FROM story WHERE story.num = \'" + storyNum + "\'";

            DataColumnCollection row = database.RetrieveRow(query);

            if (row != null)
            {
                story.Revision    = row["revision"].ValueString.ToInt();
                story.Name        = row["name"].ValueString;
                story.StoryStart  = row["story_start"].ValueString.ToInt();
                story.IsSandboxed = row["is_sandboxed"].ValueString.ToBool();
                story.ZoneID      = row["zone_id"].ValueString.ToInt();
            }

            query = "SELECT segment, " +
                    "action, " +
                    "checkpoint " +
                    "FROM story_segment WHERE story_segment.num = \'" + storyNum + "\'";

            List <DataColumnCollection> columnCollections = database.RetrieveRows(query);

            if (columnCollections == null)
            {
                columnCollections = new List <DataColumnCollection>();
            }
            foreach (DataColumnCollection columnCollection in columnCollections)
            {
                StorySegment segment = new StorySegment();

                int segmentNum = columnCollection["segment"].ValueString.ToInt();

                segment.Action = (Enums.StoryAction)columnCollection["action"].ValueString.ToInt();
                bool isCheckpoint = columnCollection["checkpoint"].ValueString.ToBool();

                string query2 = "SELECT param_key, " +
                                "param_val " +
                                "FROM story_param WHERE story_param.num = \'" + storyNum + "\' AND story_param.segment = \'" + segmentNum + "\'";

                List <DataColumnCollection> columnCollections2 = database.RetrieveRows(query2);
                if (columnCollections2 == null)
                {
                    columnCollections2 = new List <DataColumnCollection>();
                }
                foreach (DataColumnCollection columnCollection2 in columnCollections2)
                {
                    string paramKey = columnCollection2["param_key"].ValueString;
                    string paramVal = columnCollection2["param_val"].ValueString;
                    segment.Parameters.Add(paramKey, paramVal);
                }
                story.Segments.Add(segment);

                if (isCheckpoint)
                {
                    story.ExitAndContinue.Add(segmentNum);
                }
            }

            stories.Stories[storyNum] = story;
        }
 public void AppendToStory(Story story)
 {
     for (int i = 0; i < segments.Count; i++) {
         story.Segments.Add(segments[i]);
     }
 }
Beispiel #14
0
        public static void OnTournamentRoundComplete(Tournament tournament)
        {
            try {
                tournament.StartRound(new MatchUpRules());
                Story playerOneStory = new Story();
                StoryBuilderSegment playerOneSegment = StoryBuilder.BuildStory();
                StoryBuilder.AppendSaySegment(playerOneSegment, "Your match is ready to begin!", -1, 0, 0);
                StoryBuilder.AppendMovePlayerAction(playerOneSegment, 8, 2, Enums.Speed.Walking, true);
                playerOneSegment.AppendToStory(playerOneStory);

                Story playerTwoStory = new Story();
                StoryBuilderSegment playerTwoSegment = StoryBuilder.BuildStory();
                StoryBuilder.AppendSaySegment(playerTwoSegment, "Your match is ready to begin!", -1, 0, 0);
                StoryBuilder.AppendMovePlayerAction(playerTwoSegment, 11, 2, Enums.Speed.Walking, true);
                playerTwoSegment.AppendToStory(playerTwoStory);

                for (int i = 0; i < tournament.ActiveMatchups.Count; i++) {
                    StoryManager.PlayStory(tournament.ActiveMatchups[i].PlayerOne.Client, playerOneStory);
                    StoryManager.PlayStory(tournament.ActiveMatchups[i].PlayerTwo.Client, playerTwoStory);
                }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: OnTournamentRoundComplete", Text.Black);
            }
        }
Beispiel #15
0
        public static void AppendEntranceWarning(Story story, string dungeonName, string[] restrictionString)
        {
            //if (DungeonManager.Dungeons[dungeonIndex].ScriptList.ContainsKey(2)) {

            StorySegment segment = new StorySegment();

            if (restrictionString.Length == 1) {

                segment.Action = Enums.StoryAction.Say;
                segment.AddParameter("Text", "Caution!  " + GetWarningString(restrictionString[0].Split(',')));
                segment.AddParameter("Mugshot", "-1");
                segment.Parameters.Add("Speed", "0");
                segment.Parameters.Add("PauseLocation", "0");
                story.Segments.Add(segment);
                return;
            } else {

                segment.Action = Enums.StoryAction.Say;
                segment.AddParameter("Text", "Caution!  There are certain restrictions to entering " + dungeonName + ".");
                segment.AddParameter("Mugshot", "-1");
                segment.Parameters.Add("Speed", "0");
                segment.Parameters.Add("PauseLocation", "0");
                story.Segments.Add(segment);
            }

            for (int i = 0; i < restrictionString.Length; i++) {

                string warning = GetWarningString(restrictionString[i].Split(','));

                segment = new StorySegment();
                segment.Action = Enums.StoryAction.Say;

                if (i == restrictionString.Length - 1) {
                    string start = warning.Substring(0, 1).ToLower();
                    segment.AddParameter("Text", "Also, " + start + warning.Substring(1, warning.Length - 1));
                } else {
                    segment.AddParameter("Text", warning + "..");
                }

                segment.AddParameter("Mugshot", "-1");
                segment.Parameters.Add("Speed", "0");
                segment.Parameters.Add("PauseLocation", "0");
                story.Segments.Add(segment);
            }

            //} else {
            //	return null;
            //}
        }
Beispiel #16
0
        public static void QuestionResult(Client client, string questionID, string answer)
        {
            try {
                if (questionID.StartsWith("EnterRDungeon") && answer == "Yes") {
                    if (questionID.Split(':')[3] == "") {
                        client.Player.WarpToRDungeon(questionID.Split(':')[1].ToInt(), questionID.Split(':')[2].ToInt(0));
                    } else if (questionID.Split(':')[3].IsNumeric()) {
                        if (DungeonManager.Dungeons[questionID.Split(':')[3].ToInt()].ScriptList.ContainsKey(2)) {
                            //Story warningStory = DungeonRules.GetEntranceWarning(client, DungeonManager.Dungeons[questionID.Split(':')[3].ToInt()].Name,
                            //	DungeonManager.Dungeons[questionID.Split(':')[3].ToInt()].ScriptList[2].Split(';'));
                        } else {
                            client.Player.WarpToRDungeon(questionID.Split(':')[1].ToInt(), questionID.Split(':')[2].ToInt(0));
                            client.Player.AddDungeonAttempt(questionID.Split(':')[3].ToInt() - 1);
                        }
                    } else {

                    }

                }
                if (questionID.StartsWith("Level1RDungeon") && answer == "Yes") {
                    client.Player.BeginTempStatMode(questionID.Split(':')[3].ToInt(), true);
                    client.Player.WarpToRDungeon(questionID.Split(':')[1].ToInt(), questionID.Split(':')[2].ToInt(0));
                }
                if (questionID.StartsWith("SkyDrop") && answer == "Yes") {
                    string[] param = questionID.Split(':');
                    Messenger.PlayerWarp(client, param[1].ToInt(), param[2].ToInt(), param[3].ToInt());
                }

                if (questionID.StartsWith("SummonGuardian")) {

                    if (answer == "Cancel") {

                    } else if (answer == "Others") {
                        string[] idArray = questionID.Split(':');
                        int page = idArray[1].ToInt() + 1;
                            string[] choicesNum = idArray[2].Split(';');
                                if (choicesNum.Length > 1) {
                                    List<string> choices = new List<string>();
                                    if (5*page >= choicesNum.Length-1) {
                                        page = 0;
                                    }
                                    for (int i = 5*page; i < choicesNum.Length-1; i++) {
                                        if (choices.Count >= 5) {
                                            break;
                                        }
                                        choices.Add("#" + choicesNum[i] + ": " + Pokedex.GetPokemon(choicesNum[i].ToInt()).Name);
                                    }
                                    choices.Add("Others");
                                    choices.Add("Cancel");

                                    Messenger.AskQuestion(client, "SummonGuardian:"+ page + ":" + idArray[2], "Which ally will you call forth?", -1, choices.ToArray());
                                }
                    } else {
                    int legendNumber = answer.Substring(1).Split(':')[0].ToInt();

                    Messenger.PlayerMsg(client, "A light shot up from the Mystery Part, and " + Pokedex.GetPokemon(legendNumber).Name + "'s guardian sign pierced the skies asunder!", Text.Cyan);
                    Messenger.PlaySoundToMap(client.Player.MapID, "magic767.wav");
                    bool taken = false;
                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                        if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                            if (client.Player.Team[i].Species == legendNumber) {
                                taken = true;
                                break;
                            }
                        }
                    }
                    if (client.Player.PartyID != null) {
                        Party party = PartyManager.FindPlayerParty(client);
                        foreach (string memberID in party.GetMemberCharacters()) {
                            Client n = ClientManager.FindClientFromCharID(memberID);
                            if (n != null) {
                                for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                                    if (n.Player.Team[i] != null && n.Player.Team[i].Loaded) {
                                        if (n.Player.Team[i].Species == legendNumber) {
                                            taken = true;
                                            break;
                                        }
                                    }
                                }
                            } else {
                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                                    List<PMDCP.DatabaseConnector.MySql.DataColumnCollection> rows = dbConnection.Database.RetrieveRows("SELECT D.Species FROM pmdcp_players.recruit_data D " +
                                    "WHERE D.CharID = \'" + memberID + "\';");
                                    if (rows != null) {
                                    for (int i = 0; i < rows.Count; i++) {
                                        if (rows[i]["Species"].ValueString.ToInt() == legendNumber) {
                                            taken = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                                if (!taken) {
                                int openSlot = client.Player.FindOpenTeamSlot();
                                    if (openSlot > -1) {
                                        client.Player.AddToTeamTemp(openSlot,
                                            legendNumber,
                                            0,
                                            100, (Constants.MAX_JOB_LIST + openSlot));
                                        Messenger.PlayerMsg(client, Server.Pokedex.Pokedex.GetPokemon(legendNumber).Name +
                                            " joined the team!", Text.BrightGreen);
                                        Messenger.SendActiveTeam(client);

                                    }
                                } else {
                                    Messenger.PlayerMsg(client, "But " + Server.Pokedex.Pokedex.GetPokemon(legendNumber).Name +
                                            " is already an ally!", Text.BrightGreen);
                                }
                            }
                }

                if (questionID.StartsWith("UseItem")) {
                            if (answer == "Yes") {
                                int num = questionID.Split(':')[1].ToInt();
                                int slot = 0;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num == num && !client.Player.Inventory[i].Sticky) {
                                        slot = i;
                                        break;
                                    }
                                }
                                //Messenger.PlayerMsg(client, "yes" + slot, Text.Blue);
                                if (slot > 0) {
                                    client.Player.UseItem(client.Player.Inventory[slot], slot);
                                }
                            }
                }

                // Called when a player answers a yes/no question
                switch (questionID) {
                    case "Appraisal": {
                            if (answer == "Yes") {
                                int boxes = 0;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num != 0
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Type == Enums.ItemType.Scripted
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Data1 == 12
                                        && !client.Player.Inventory[i].Sticky) {
                                        boxes++;
                                    }
                                }
                                if (client.Player.HasItem(1) >= 150 * boxes) {
                                    client.Player.TakeItem(1, 150 * boxes, true);
                                    for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                        if (client.Player.Inventory[i].Num != 0
                                            && ItemManager.Items[client.Player.Inventory[i].Num].Type == Enums.ItemType.Scripted
                                            && ItemManager.Items[client.Player.Inventory[i].Num].Data1 == 12
                                            && !client.Player.Inventory[i].Sticky) {
                                            OpenBox(client, client.Player.Inventory[i], i);
                                        }
                                    }
                                    Messenger.PlaySoundToMap(client.Player.MapID, "magic227.wav");
                                    Story story = new Story();
                                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                    StoryBuilder.AppendSaySegment(segment, "All treasure boxes were opened!", -1, 0, 0);
                                    segment.AppendToStory(story);
                                    StoryManager.PlayStory(client, story);
                                } else {
                                    Messenger.PlayerMsg(client, "You do not have enough to open your boxes!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "Unsticky": {
                            if (answer == "Yes") {
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Sticky) {
                                        client.Player.SetItemSticky(i, false);
                                    }
                                }
                                Messenger.PlaySoundToMap(client.Player.MapID, "magic231.wav");
                                //Messenger.PlayerMsg(client, "All sticky items have been cleansed!", Text.Cyan);
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "All sticky items have been cleansed!", -1, 0, 0);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);
                            }
                        }
                        break;
                    case "TradeEgg": {
                            if (answer == "Yes") {
                                int takenItem = 0;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num == 110 || client.Player.Inventory[i].Num == 109 || client.Player.Inventory[i].Num == 131) {
                                        takenItem = i;
                                    }
                                }
                                Messenger.PlaySoundToMap(client.Player.MapID, "magic693.wav");
                                client.Player.TakeItemSlot(takenItem, 1, true);
                                client.Player.GiveItem(538, 1, "641;642;643;644;645;646;647;648;649;650;651;652;653;654;655;656;657;" +
                                    "661;662;663;664;665;666;667;668;669;670;671;672;673;674;675;676;677", false);
                                //Messenger.PlayerMsg(client, "You were given a gift in exchange for the Egg!", Text.BrightGreen);
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "You were given a gift in exchange for the Egg!", -1, 0, 0);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);

                            } else {
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "Well, then I hope you take good care of it!", Pokedex.FindByName("Togekiss").ID, 0, 0);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);
                            }
                        }
                        break;
                    case "RecallEggMove": {
                            if (answer == "Yes") {

                                client.Player.TakeItem(702, 1, true);
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "Okay, here goes!", Pokedex.FindByName("Togetic").ID, 0, 0);
                                StoryBuilder.AppendRunScriptAction(segment, 48, "", "", "", true);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);

                            } else {
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "Well, alright then!  Let me know when you feel like learning something fun!", Pokedex.FindByName("Togetic").ID, 0, 0);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);
                            }
                        }
                        break;
                    case "LearnTutorMove": {
                            int item = 0;
                            if (answer == ItemManager.Items[263].Name) {
                                item = 263;
                            } else if (answer == ItemManager.Items[264].Name) {
                                item = 264;
                            } else if (answer == ItemManager.Items[265].Name) {
                                item = 265;
                            } else if (answer == ItemManager.Items[266].Name) {
                                item = 266;
                            }

                            if (item > 0 && client.Player.HasItem(item) > 0) {
                                client.Player.TakeItem(item, 1, true);
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "Very well, let us commence!", Pokedex.FindByName("Bronzong").ID, 0, 0);
                                StoryBuilder.AppendRunScriptAction(segment, 71, item.ToString(), "", "", true);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);

                            } else {
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "Very well.  I shall wait here until you wish to part with your shards.", Pokedex.FindByName("Bronzong").ID, 0, 0);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);
                            }
                        }
                        break;
                    case "ShellBell": {
                            if (answer == "Yes") {
                                int shellCount = 0;
                                int saltCount = 0;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num == 96) {
                                        shellCount++;
                                    } else if (client.Player.Inventory[i].Num == 102) {
                                        saltCount++;
                                    }
                                }

                                if (saltCount >= 5 && shellCount >= 5) {
                                    for (int i = 0; i < 5; i++) {
                                        client.Player.TakeItem(96, 1, true);
                                        client.Player.TakeItem(102, 1, true);
                                    }

                                    Story story = new Story();
                                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                    StoryBuilder.AppendSaySegment(segment, "Okay, just give me a moment...", Pokedex.FindByName("Oshawott").ID, 0, 0);
                                    StoryBuilder.AppendPauseAction(segment, 1500);
                                    StoryBuilder.AppendSaySegment(segment, "Ta-da!  Here you go!", Pokedex.FindByName("Oshawott").ID, 0, 0);
                                    StoryBuilder.AppendRunScriptAction(segment, 35, "", "", "", true);
                                    StoryBuilder.AppendPauseAction(segment, 1000);

                                    StoryBuilder.AppendAskQuestionAction(segment, "So what'ja think?  You like it?", segment.Segments.Count + 2, segment.Segments.Count + 4, Pokedex.FindByName("Oshawott").ID);

                                    StoryBuilder.AppendSaySegment(segment, "Awww, gee... thanks!", Pokedex.FindByName("Oshawott").ID, 0, 0);
                                    StoryBuilder.AppendGoToSegmentAction(segment, segment.Segments.Count + 5);
                                    StoryBuilder.AppendSaySegment(segment, "Oh...", Pokedex.FindByName("Oshawott").ID, 0, 0);
                                    StoryBuilder.AppendPauseAction(segment, 500);
                                    StoryBuilder.AppendSaySegment(segment, "I'm sorry...", Pokedex.FindByName("Oshawott").ID, 0, 0);

                                    segment.AppendToStory(story);
                                    StoryManager.PlayStory(client, story);
                                }
                            } else {
                                Story story = new Story();
                                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                StoryBuilder.AppendSaySegment(segment, "You- you don't?", Pokedex.FindByName("Oshawott").ID, 0, 0);
                                StoryBuilder.AppendSaySegment(segment, "Well... okay...", Pokedex.FindByName("Oshawott").ID, 0, 0);
                                segment.AppendToStory(story);
                                StoryManager.PlayStory(client, story);
                            }
                        }
                        break;
                    case "HouseSpawn": {
                            if (answer == "Yes") {
                                if (client.Player.Map.MapType == Server.Enums.MapType.House &&
                                    ((House)client.Player.Map).OwnerID == client.Player.CharID) {
                                        if (client.Player.HasItem(1) >= 500) {
                                            client.Player.TakeItem(1, 500, true);
                                            ((House)client.Player.Map).StartX = client.Player.X;
                                            ((House)client.Player.Map).StartY = client.Player.Y;
                                            client.Player.Map.Save();
                                            Messenger.PlayerMsg(client, "You have set your house's entrance point!", Text.BrightGreen);
                                        } else {
                                            Messenger.PlayerMsg(client, "You don't have enough " + ItemManager.Items[1].Name + "!", Text.BrightRed);
                                        }
                                } else {
                                    Messenger.PlayerMsg(client, "You can't set your house entrance here!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "HouseRoof": {
                            if (answer == "Yes") {
                                if (client.Player.Map.MapType == Server.Enums.MapType.House &&
                                    ((House)client.Player.Map).OwnerID == client.Player.CharID) {
                                        if (client.Player.HasItem(1) >= 500) {
                                            client.Player.TakeItem(1, 500, true);
                                            client.Player.Map.Indoors = !client.Player.Map.Indoors;
                                            client.Player.Map.Save();
                                            if (client.Player.Map.Indoors) {
                                                Messenger.PlayerMsg(client, "You have closed your house's roof!", Text.BrightGreen);
                                            } else {
                                                Messenger.PlayerMsg(client, "You have opened your house's roof!", Text.BrightGreen);
                                            }
                                            Messenger.RefreshMap(client);
                                        } else {
                                            Messenger.PlayerMsg(client, "You don't have enough " + ItemManager.Items[1].Name + "!", Text.BrightRed);
                                        }
                                } else {
                                    Messenger.PlayerMsg(client, "You can't set your house entrance here!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "DiglettMission": {
                            if (answer == "Yes") {
                                StoryManager.PlayStory(client, 415);
                            } else {
                                StoryManager.PlayStory(client, 414);
                            }
                        }
                        break;
                    case "FerryTicketUse": {//originally used in place of Keyblocks during exploitations of the Refresh Glitch.
                            if (answer == "Yes") {
                                client.Player.TakeItem(49, 1);
                                Messenger.PlayerWarp(client, 880, 16, 12);
                            } else {
                                Messenger.PlayerMsg(client, "Ok. Come back later!", Text.Yellow);
                            }
                        }
                        break;
                    case "MassWarpAuction": {
                            if (answer == "Yes") {
                                Messenger.PlayerWarp(client, 363, 10, 13);
                            }
                        }
                        break;
                    case "WarptoForlorn": {
                            if (answer == "Yes") {
                                Messenger.PlayerWarp(client, 684, 4, 29);
                            }
                            //if (answer == true) {
                            //    NetScript.PlayerWarp(index, 1109, 10, 7);
                            //}
                        }
                        break;
                    case "WarptoTanren": {
                            if (answer == "Yes") {
                                Messenger.PlayerWarp(client, 78, 37, 19);
                            }
                            //if (answer == true) {
                            //    NetScript.PlayerWarp(index, 390, 9, 10);
                            //}
                        }
                        break;
                    case "uselotteryticket": {
                            if (answer == "Yes") {
                                Lottery.VerifyWinner(client);
                            }
                        }
                        break;
                    case "buylotteryticket": {
                            if (answer == "Yes") {
                                Lottery.BuyLotteryTicket(client);
                            }
                        }
                        break;
                    case "Fireplace": {
                            if (answer == "Yes") {
                                //Messenger.SpellAnim(452, client.Player.MapID, 15, 4);
                                Messenger.PlaySoundToMap(client.Player.MapID, "magic68.wav");
                                StoryManager.PlayStory(client, 35);
                            }
                        }
                        break;
                    case "Surf": {
                            if (answer == "Yes") {
                                int surfSlot = -1;
                                for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                                    if (client.Player.GetActiveRecruit().Moves[i].MoveNum == 462) {
                                        surfSlot = i;
                                    }
                                }

                                if (surfSlot > -1) {
                                    client.Player.GetActiveRecruit().UseMove(surfSlot);
                                }
                            }
                        }
                        break;
                    case "RockClimb": {
                            if (answer == "Yes") {
                                int surfSlot = -1;
                                for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                                    if (client.Player.GetActiveRecruit().Moves[i].MoveNum == 456) {
                                        surfSlot = i;
                                    }
                                }

                                if (surfSlot > -1) {
                                    client.Player.GetActiveRecruit().UseMove(surfSlot);
                                }
                            }
                        }
                        break;
                    case "AbandonedMansion": {
                            if (answer == "Yes") {
                                StoryManager.PlayStory(client, 297);
                                //NetScript.AskQuestion(index, "AbandonedMansion2", "Only the team leader may enter this dungeon, is that OK?", -1);
                            }
                        }
                        break;
                    case "AbandonedMansion2": {
                            //Debug.Print("---");
                            if (answer == "Yes") {
                                if (client.Player.MapID == MapManager.GenerateMapID(743)) {
                                    if (client.Player.X == 11) {
                                        Messenger.PlaySoundToMap(client.Player.MapID, "key.wav");
                                        client.Player.TakeItem(249, 1);
                                        Messenger.PlayerMsg(client, "The key dissolves.", Text.Yellow);
                                        client.Player.WarpToRDungeon(16, 0);
                                    } else if (client.Player.X == 21) {
                                        Messenger.PlaySoundToMap(client.Player.MapID, "key.wav");
                                        client.Player.TakeItem(248, 1);
                                        Messenger.PlayerMsg(client, "The key dissolves.", Text.Yellow);
                                        client.Player.WarpToRDungeon(15, 0);
                                    } else if (client.Player.X == 16) {
                                        Messenger.PlaySoundToMap(client.Player.MapID, "key.wav");
                                        client.Player.TakeItem(252, 1);
                                        Messenger.PlayerMsg(client, "The key dissolves.", Text.Yellow);
                                        client.Player.WarpToRDungeon(17, 0);
                                    }
                                }
                            }
                        }
                        break;
                    case "WarptoPokehallow": {
                            if (answer == "Yes") {
                                Messenger.PlayerWarp(client, 743, 16, 11);
                            }
                        }
                        break;
                    case "HallowedWell": {
                            if (answer == "Yes") {
                                StoryManager.PlayStory(client, 294);
                            }
                        }
                        break;
                    case "HallowedWell2": {
                            if (answer == "Yes") {
                                Messenger.PlaySoundToMap(client.Player.MapID, "DeepFall.wav");
                                client.Player.WarpToRDungeon(20, 0);
                            }
                        }
                        break;
                    case "AfterDeath": {
                        switch (answer) {
                            case "Revive": {
                                    AskReviveQuestion(client);
                                }
                                break;
                            case "Switch": {
                                    AskRecruitSwapQuestion(client);
                                }
                                break;
                            case "Escape": {
                                    Messenger.AskQuestion(client, "Escape", "Will you use your Escape Rope to retreat from the dungeon?  It will not count as a defeat.", -1);
                                }
                                break;
                            case "Give Up": {
                                    GiveUp(client);
                                }
                                break;
                            }

                        }
                        break;
                    case "AfterDeathRevive": {
                            if (answer == ItemManager.Items[489].Name) {
                                ActivateRevivalItem(client, 489);
                            } else if (answer == ItemManager.Items[452].Name) {
                                ActivateRevivalItem(client, 452);
                            } else if (answer == ItemManager.Items[451].Name) {
                                ActivateRevivalItem(client, 451);
                            } else if (answer == ItemManager.Items[450].Name) {
                                ActivateRevivalItem(client, 450);
                            } else if (answer == ItemManager.Items[749].Name) {
                                ActivateRevivalItem(client, 749);
                            } else {
                                AskAfterDeathQuestion(client);
                            }
                        }
                        break;
                    case "AfterDeathSwap": {
                        if (answer.StartsWith("Slot #")) {
                            int slot = answer.Substring(6).ToInt() - 1;
                            int activeSlot = client.Player.ActiveSlot;
                            string name = client.Player.GetActiveRecruit().Name;

                            List<ExtraStatus> passedStatus = GetTeamStatus(client.Player.GetActiveRecruit());

                            foreach (ExtraStatus status in passedStatus) {
                                client.Player.GetActiveRecruit().VolatileStatus.Add(status);
                                Messenger.BattleMsg(client, status.Name, Text.BrightRed);
                            }

                            client.Player.SwapActiveRecruit(slot, true);
                            client.Player.RestoreRecruitStats(activeSlot);

                            client.Player.RemoveFromTeam(activeSlot);

                            client.Player.Dead = false;
                            PacketHitList hitlist = null;
                            PacketHitList.MethodStart(ref hitlist);
                            PacketBuilder.AppendDead(client, hitlist);
                            PacketHitList.MethodEnded(ref hitlist);

                            Messenger.SendActiveTeam(client);
                        } else {
                            AskAfterDeathQuestion(client);
                        }
                        }
                        break;
                    case "GiveUp": {
                            if (answer == "Yes") {
                                Messenger.MapMsg(client.Player.MapID, client.Player.Name + " has given-up on the exploration!", Text.BrightRed);
                                client.Player.GetActiveRecruit().StatusAilment = Enums.StatusAilment.OK;
                                client.Player.GetActiveRecruit().StatusAilmentCounter = 0;
                                HandleGameOver(client, Enums.KillType.Other);
                            } else if (client.Player.Dead) {
                                AskAfterDeathQuestion(client);
                            }
                        }
                        break;
                    case "Escape": {
                            if (answer == "Yes") {
                                int slot = 0;

                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num == 350 && !client.Player.Inventory[i].Sticky) {
                                        slot = i;
                                        break;
                                    }
                                }

                                if (slot > 0) {
                                    client.Player.TakeItemSlot(slot, 1, true);
                                    Escape(client);
                                } else {
                                    Messenger.MapMsg(client.Player.MapID, client.Player.Name + " couldn't escape!", Text.BrightRed);
                                }

                            } else if (client.Player.Dead) {
                                AskAfterDeathQuestion(client);
                            }
                        }
                        break;
                    case "TradeItem": {
                            if (answer == "Yes") {
                                int itemTaken = client.Player.FindInvSlot(110);
                                if (client.Player.FindInvSlot(109) > itemTaken) {
                                    itemTaken = client.Player.FindInvSlot(109);
                                }
                                if (client.Player.FindInvSlot(131) > itemTaken) {
                                    itemTaken = client.Player.FindInvSlot(131);
                                }
                                if (itemTaken > -1) {
                                    client.Player.TakeItemSlot(itemTaken, 1, true);
                                    client.Player.GiveItem(538, 1, "38;45;125;290;194;299;300;301;302");
                                }
                            }
                        }
                        break;
                    case "CliffsideTablet": {
                            if (answer == "Yes") {
                                if (client.Player.FindInvSlot(-1) > 0) {
                                    client.Player.GiveItem(479, 1);
                                    IMap map = client.Player.Map;
                                    map.SetTile(10, 1, 0, 10, 3);
                                    map.SetTile(10, 1, 0, 10, 4);
                                    map.SetAttribute(10, 1, Enums.TileType.Blocked, 0, 0, 0, "0", "0", "0");
                                    Messenger.SendTile(10, 1, map);
                                    Messenger.PlayerMsg(client, "You obtained a Tablet!", Text.Yellow);
                                } else {
                                    Messenger.PlayerMsg(client, "Your inventory is full...", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "TournamentAdminOptions": {
                            if (answer == "Start Tournament") {
                                if (client.Player.Tournament != null) {
                                    Tournament tourny = client.Player.Tournament;
                                    if (tourny.RegisteredMembers[client].Admin) {
                                        if (tourny.IsReadyToStart()) {
                                            tourny.StartRound(new MatchUpRules());

                                            Story playerOneStory = new Story();
                                            StoryBuilderSegment playerOneSegment = StoryBuilder.BuildStory();
                                            StoryBuilder.AppendSaySegment(playerOneSegment, "Your match is ready to begin!", -1, 0, 0);
                                            StoryBuilder.AppendMovePlayerAction(playerOneSegment, 8, 2, Enums.Speed.Walking, true);
                                            playerOneSegment.AppendToStory(playerOneStory);

                                            Story playerTwoStory = new Story();
                                            StoryBuilderSegment playerTwoSegment = StoryBuilder.BuildStory();
                                            StoryBuilder.AppendSaySegment(playerTwoSegment, "Your match is ready to begin!", -1, 0, 0);
                                            StoryBuilder.AppendMovePlayerAction(playerTwoSegment, 11, 2, Enums.Speed.Walking, true);
                                            playerTwoSegment.AppendToStory(playerTwoStory);

                                            for (int i = 0; i < tourny.ActiveMatchups.Count; i++) {
                                                StoryManager.PlayStory(tourny.ActiveMatchups[i].PlayerOne.Client, playerOneStory);
                                                StoryManager.PlayStory(tourny.ActiveMatchups[i].PlayerTwo.Client, playerTwoStory);
                                            }
                                        } else {
                                            Messenger.PlayerMsg(client, "The tournament is not ready to start!", Text.BrightRed);
                                        }
                                    }
                                }
                            } else if (answer == "Edit Rules") {
                                if (client.Player.Tournament != null) {
                                    Tournament tourny = client.Player.Tournament;
                                    if (tourny.RegisteredMembers[client].Admin) {
                                        Messenger.SendTournamentRulesEditorTo(client, null);
                                    } else {
                                        Messenger.PlayerMsg(client, "You are not a tournament organizer!", Text.BrightRed);
                                    }
                                }
                            }
                        }
                        break;
                   case "SnowballGameNewGame": {
                   			if (answer == "Yes") {
                   				string waitingGameOwner = SnowballGame.FindWaitingGame();
                   				if (!string.IsNullOrEmpty(waitingGameOwner)) {
                   					Messenger.PlayerMsg(client, "Someone else created a game, please join that game.", Text.BrightRed);
                   					return;
                   				}
                   				SnowballGame snowballGame = new SnowballGame();
                   				snowballGame.Init();
                   				snowballGame.CreateGame(client);

                   				ActiveSnowballGames.Add(client.Player.CharID, snowballGame);
                   				Messenger.MapMsg(client.Player.MapID, client.Player.Name + " created a new game!", Text.BrightGreen);
                   			}
                       }
                       break;
                   case "SnowballGameJoinGame": {
                   			if (answer == "Yes") {
                   				// Join game here

                   				SnowballGame.GetWaitingGame().AddToGame(client);
                   			}
                       }
                       break;
                   case "SnowballGameStart": {
                   			if (answer == "Yes") {
                   				// Star game here

                   				//Messenger.MapMsg(client.Player.MapID, client.Player.Name + " started the game!", Text.BrightGreen);
                   				//Messenger.PlayerMsg(client, "Pretend you started the game.", Text.BrightGreen);
                   				SnowballGame.GetWaitingGame().StartGame(client);
                   			}
                       }
                       break;
                   case "SwapShopTeamList": {
                         if (answer == "Proceed") {

                         List<string> choices = new List<string>();
                         choices.Add(Pokedex.GetPokemon(client.Player.Team[0].Species).Name);
                  		   for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                     		  if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                      		    if (i > 0 && client.Player.Team[i].Species != client.Player.Team[i - 1].Species && client.Player.Team[i].Species != client.Player.Team[0].Species) {
                       			   choices.Add(Pokedex.GetPokemon(client.Player.Team[i].Species).Name);
                          }
                       }
                       }
                          Messenger.AskQuestion(client, "SwapShopItemList", "Whose list of rare exclusive items do you want to see?", Pokedex.FindByName("Croagunk").ID, choices.ToArray());
                           }
                         if (answer == "Summary") {

                         List<string> choices = new List<string>();
                         choices.Add(Pokedex.GetPokemon(client.Player.Team[0].Species).Name);
                  		   for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                     		  if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                      		    if (i > 0 && client.Player.Team[i].Species != client.Player.Team[i - 1].Species && client.Player.Team[i].Species != client.Player.Team[0].Species) {
                       			   choices.Add(Pokedex.GetPokemon(client.Player.Team[i].Species).Name);
                          }
                       }
                       }
                          Messenger.AskQuestion(client, "SwapShopItemSummaryList", "Whose list of rare exclusive items do you want to know about?", Pokedex.FindByName("Croagunk").ID, choices.ToArray());
                           }
                         if (answer == "Cancel") {
                          Story story = new Story();
                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          StoryBuilder.AppendSaySegment(segment, "You don't wanna swap? Meh-heh-heh... I get it!", Pokedex.FindByName("Croagunk").ID, 0, 0);
                          segment.AppendToStory(story);
                          StoryManager.PlayStory(client, story);
                            }
                         }
                        break;
                      case "SwapShopItemSummaryList" : {
                      int ItemFound = 0;
                      int PokemonID = Pokedex.FindByName(answer).ID;
                      List<string> choices = new List<string>();
                      for (int i = 998; i < 1838; i++) {

                        if (Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData1 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData2 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData3 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData4 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData5) {
                          if (ItemManager.Items[i].Rarity == 3) {
                            choices.Add(ItemManager.Items[i].Name);
                            ItemFound = ItemFound + 1;
                            }
                          }
                          }
                      choices.Add("Cancel");
                     if (ItemFound == 0) {
                          Story story = new Story();
                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          StoryBuilder.AppendSaySegment(segment, "Meh-heh-heh... I'm sorry to disappoint you but I'm afraid that " + answer + " has no rare exclusive items to use at the moment...", Pokedex.FindByName("Croagunk").ID, 0, 0);
                          StoryBuilder.AppendRunScriptAction(segment, 90, "", "", "", true);
                          segment.AppendToStory(story);
                          StoryManager.PlayStory(client, story);
                       }
                     if (ItemFound == 1) {
                      Messenger.AskQuestion(client, "SwapShopItemSummary", "Here is the rare exclusive item that " + answer + " can use...", Pokedex.FindByName("Croagunk").ID, choices.ToArray());
                       }
                     if (ItemFound > 1) {
                      Messenger.AskQuestion(client, "SwapShopItemSummary", "Here are the rare exclusive items that " + answer + " can use...", Pokedex.FindByName("Croagunk").ID, choices.ToArray());
                      }
                      }
                        break;
                      case "SwapShopItemList": {
                      int ItemFound = 0;
                      int PokemonID = Pokedex.FindByName(answer).ID;
                      List<string> choices = new List<string>();
                      for (int i = 998; i < 1838; i++) {

                        if (Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData1 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData2 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData3 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData4 || Pokedex.FindByName(answer).ID == ItemManager.Items[i].ReqData5) {
                          if (ItemManager.Items[i].Rarity == 3) {
                            choices.Add(ItemManager.Items[i].Name);
                            ItemFound = ItemFound + 1;
                            }
                          }
                          }
                      choices.Add("Cancel");
                     if (ItemFound == 0) {
                          Story story = new Story();
                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          StoryBuilder.AppendSaySegment(segment, "Meh-heh-heh... I'm sorry to disappoint you but I'm afraid that " + answer + " has no rare exclusive items to use at the moment...", Pokedex.FindByName("Croagunk").ID, 0, 0);
                          segment.AppendToStory(story);
                          StoryManager.PlayStory(client, story);
                       }
                     if (ItemFound == 1) {
                      Messenger.AskQuestion(client, "SwapShopReq", "Here is the rare exclusive item that " + answer + " can use...", Pokedex.FindByName("Croagunk").ID, choices.ToArray());
                       }
                     if (ItemFound > 1) {
                      Messenger.AskQuestion(client, "SwapShopReq", "Here are the rare exclusive items that " + answer + " can use...", Pokedex.FindByName("Croagunk").ID, choices.ToArray());
                      }
                      }
                        break;
                      case "SwapShopItemSummary": {
                      string ItemReq1;
                      ItemReq1 = "";
                      string ItemReq2;
                      ItemReq2 = "";
                      string ItemReq3 = "";
                      ItemReq3 = "";
                      string ItemReqAny;
                      ItemReqAny = "";
                      string ItemYour;
                      ItemYour = "";
                      int ReqFound = 0;
                      int Item1 = 0;
                      int Item2 = 0;
                      int Item3 = 0;
                      int SwapItemNum = 0;
                      string SwapItem;
                      SwapItem = answer;
                      for (int c = 998; c < 1838; c++) {
                            if (ItemManager.Items[c].Name.Contains(answer)) {
                            int PokemonID = ItemManager.Items[c].ReqData1;
                            SwapItemNum = c;
                        for (int i = 998; i < 1838; i++) {
                         if (PokemonID == ItemManager.Items[i].ReqData1) {
                           if (ItemManager.Items[i].Rarity == 1 || ItemManager.Items[i].Rarity == 2) {
                            ReqFound = ReqFound + 1;
                              if (ReqFound == 1) {
                              ItemReq1 = ItemManager.Items[i].Name;
                              ItemYour = "your ";
                              Item1 = i;
                              }
                              if (ReqFound == 2) {
                              ItemReq2 = ", " + ItemManager.Items[i].Name;
                              Item2 = i;
                              }
                              if (ReqFound == 3) {
                              ItemReq3 = " and " + ItemManager.Items[i].Name;
                              Item3 = i;
                              }
                          } else if (ReqFound == 0) {
                          ItemReqAny = "five different exclusive items";
                          ItemYour = "any ";
                          }
                          }
                          }
                          }
                          }
                          if (answer != "Cancel") {
                          Story summary = new Story();
                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          StoryBuilder.AppendSaySegment(segment, "" + answer + "? " + ItemManager.Items[SwapItemNum].Desc, Pokedex.FindByName("Croagunk").ID, 0, 0);
                          StoryBuilder.AppendSaySegment(segment, "In order to obtain " + answer + ", one must swap " + ItemReq1 + ItemReq2 + ItemReq3 + ItemReqAny + " for it.", Pokedex.FindByName("Croagunk").ID, 0, 0);
                          StoryBuilder.AppendRunScriptAction(segment, 90, "", "", "", true);

                          segment.AppendToStory(summary);
                          StoryManager.PlayStory(client, summary);
                         }
                          if (answer == "Cancel") {
                          Story cancel = new Story();
                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          StoryBuilder.AppendRunScriptAction(segment, 90, "", "", "", true);
                          segment.AppendToStory(cancel);
                          StoryManager.PlayStory(client, cancel);
                          }

                  }
                        break;
                      case "SwapShopReq": {
                      string ItemReq1;
                      ItemReq1 = "";
                      string ItemReq2;
                      ItemReq2 = "";
                      string ItemReq3 = "";
                      ItemReq3 = "";
                      string ItemReqAny;
                      ItemReqAny = "";
                      string ItemYour;
                      ItemYour = "";
                      int ReqFound = 0;
                      int Item1 = 0;
                      int Item2 = 0;
                      int Item3 = 0;
                      int SwapItemNum = 0;
                      string SwapItem;
                      if (answer != "Cancel") {
                      SwapItem = answer;
                      List<string> choices = new List<string>();
                      choices.Add("Yes, I want to Swap for " + answer);
                      choices.Add("Cancel");
                      for (int c = 998; c < 1838; c++) {
                            if (ItemManager.Items[c].Name.Contains(answer)) {
                            int PokemonID = ItemManager.Items[c].ReqData1;
                            SwapItemNum = c;
                        for (int i = 998; i < 1838; i++) {
                         if (PokemonID == ItemManager.Items[i].ReqData1) {
                           if (ItemManager.Items[i].Rarity == 1 || ItemManager.Items[i].Rarity == 2) {
                            ReqFound = ReqFound + 1;
                              if (ReqFound == 1) {
                              ItemReq1 = ItemManager.Items[i].Name;
                              ItemYour = "your ";
                              Item1 = i;
                              }
                              if (ReqFound == 2) {
                              ItemReq2 = ", " + ItemManager.Items[i].Name;
                              Item2 = i;
                              }
                              if (ReqFound == 3) {
                              ItemReq3 = " and " + ItemManager.Items[i].Name;
                              Item3 = i;
                              }
                          } else if (ReqFound == 0) {
                          ItemReqAny = "five different exclusive items";
                          ItemYour = "any ";
                          }
                          }
                          }
                          }
                          }

                             Messenger.AskQuestion(client, "SwapShopActive", "So you want " + answer + " and wanna swap " + ItemYour + ItemReq1 + ItemReq2 + ItemReq3 + ItemReqAny + " for that? It'll cost ya 5000 Poké, too. Is that okay?", Pokedex.FindByName("Croagunk").ID, choices.ToArray());
                             }
                          else {
                          Story cancel = new Story();
                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          StoryBuilder.AppendSaySegment(segment, "You don't wanna swap? Meh-heh-heh... I get it!", Pokedex.FindByName("Croagunk").ID, 0, 0);
                          segment.AppendToStory(cancel);
                          StoryManager.PlayStory(client, cancel);
                          }

                  }
                        break;
                      case "SwapShopActive" : {
                             string ItemName;
                             ItemName = answer.Replace("Yes, I want to Swap for ", "");
                             int ReqFound = 0;
                             int SwapItemNum = 0;
                             int Item1 = 0;
                             int Item2 = 0;
                             int Item3 = 0;
                             int PokemonID = 0;
                      for (int c = 998; c < 1838; c++) {
                            if (ItemManager.Items[c].Name.Contains(ItemName)) {
                             PokemonID = ItemManager.Items[c].ReqData1;
                            SwapItemNum = c;
                        for (int i = 998; i < 1838; i++) {
                         if (PokemonID == ItemManager.Items[i].ReqData1) {
                           if (ItemManager.Items[i].Rarity == 1 || ItemManager.Items[i].Rarity == 2) {
                            ReqFound = ReqFound + 1;
                              if (ReqFound == 1) {
                              Item1 = i;
                              }
                              if (ReqFound == 2) {
                              Item2 = i;
                              }
                              if (ReqFound == 3) {
                              Item3 = i;
                              }
                          }
                          }
                          }
                          }
                          }
                          if (answer != "Cancel") {
                              if (ReqFound > 0) {
                                      if (client.Player.HasItem(Item1) > 0 && client.Player.HasItem(Item2) > 0 && client.Player.HasItem(Item3) > 0 && client.Player.HasItem(1) >= 5000) {
                              		  Messenger.SpellAnim(491, client.Player.MapID, client.Player.X, client.Player.Y);
                                      Story story = new Story();
                                      StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                      StoryBuilder.AppendRunScriptAction(segment, 5, "magic162.ogg", "", "", true);
                                      StoryBuilder.AppendPauseAction(segment, 500);
                                      StoryBuilder.AppendSaySegment(segment, "Meh-heh-heh! Seems that we brewed up a successful swap there! Here... Take your unbelievably valuable " + ItemName + "! Treat it with respect! Meh-heh-heh!", Pokedex.FindByName("Croagunk").ID, 0, 0);
                                      StoryBuilder.AppendPauseAction(segment, 500);
                                      StoryBuilder.AppendRunScriptAction(segment, 90, "", "", "", true);
                                      segment.AppendToStory(story);
                                      StoryManager.PlayStory(client, story);
                                      client.Player.TakeItem(Item1, 1);
                                      client.Player.TakeItem(Item2, 1);
                                      client.Player.TakeItem(Item3, 1);
                                      client.Player.TakeItem(1, 5000);
                                      client.Player.GiveItem(SwapItemNum, 1, "", false);
                                    }
                                    else {
                                      Story no = new Story();
                                      StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                      StoryBuilder.AppendSaySegment(segment, "Meh-heh-heh? I'm sorry... You don't seem to have the required items for the Swap process...", Pokedex.FindByName("Croagunk").ID, 0, 0);
                                      StoryBuilder.AppendRunScriptAction(segment, 90, "", "", "", true);
                                      segment.AppendToStory(no);
                                      StoryManager.PlayStory(client, no);
                                      }
                                      }
                               else {
                               int ItemCount = 0;
                               int Take1 = 0;
                               int Take2 = 0;
                               int Take3 = 0;
                               int Take4 = 0;
                               int Take5 = 0;
                                for (int b = 1; b <= client.Player.Inventory.Count; b++) {
                                int i = client.Player.Inventory[b].Num;
                                 if (i >= 998 && i < 1838) {
                                     if (client.Player.HasItem(i) > 0 && ItemCount == 0) {
                                      Take1 = i;
                                      ItemCount++;
                                      }
                                     if (client.Player.HasItem(i) > 0 && i != Take1 && ItemCount == 1) {
                                      Take2 = i;
                                      ItemCount++;
                                      }
                                     if (client.Player.HasItem(i) > 0 && i != Take1 && i != Take2 && ItemCount == 2) {
                                      Take3 = i;
                                      ItemCount++;
                                      }
                                     if (client.Player.HasItem(i) > 0 && i != Take1 && i != Take2 && client.Player.Inventory[b].Num != Take3 && ItemCount == 3) {
                                      Take4 = i;
                                      ItemCount++;
                                      }
                                     if (client.Player.HasItem(i) > 0 && i != Take1 && i != Take2 && client.Player.Inventory[b].Num != Take3 && client.Player.Inventory[b].Num != Take4 && ItemCount >= 4) {
                                      Take5 = i;
                                      ItemCount++;
                                      }
                                      }
                               }
                                  //  Messenger.PlayerMsg(client, Take1 + "|" + Take2 + "|" + Take3 + "|" + Take4 + "|" + Take5 + "|" +ItemCount, Text.Yellow); // Debug Message
                                   if (ItemCount >= 5 && client.Player.HasItem(1) >= 5000) {
                                        Messenger.SpellAnim(491, client.Player.MapID, client.Player.X, client.Player.Y);
                                        Story yes = new Story();
                                        StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                        StoryBuilder.AppendRunScriptAction(segment, 5, "magic162.ogg", "", "", true);
                                        StoryBuilder.AppendPauseAction(segment, 500);
                                        StoryBuilder.AppendSaySegment(segment, "Meh-heh-heh! Seems that we brewed up a successful swap there! Here... Take your unbelievably valuable " + ItemName + "! Treat it with respect! Meh-heh-heh!", Pokedex.FindByName("Croagunk").ID, 0, 0);
                                        StoryBuilder.AppendPauseAction(segment, 500);
                                        StoryBuilder.AppendRunScriptAction(segment, 90, "", "", "", true);
                                        segment.AppendToStory(yes);
                                        StoryManager.PlayStory(client, yes);
                                        client.Player.TakeItem(Take1, 1, true);
                                        client.Player.TakeItem(Take2, 1, true);
                                        client.Player.TakeItem(Take3, 1, true);
                                        client.Player.TakeItem(Take4, 1, true);
                                        client.Player.TakeItem(Take5, 1, true);
                                        client.Player.TakeItem(1, 5000, true);
                                        client.Player.GiveItem(SwapItemNum, 1, "", false);
                                        } else if (ItemCount < 5 || client.Player.HasItem(1) < 5000) {
                                          Story no = new Story();
                                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                          StoryBuilder.AppendSaySegment(segment, "Meh-heh-heh? I'm sorry... You don't seem to have the required items for the Swap process...", Pokedex.FindByName("Croagunk").ID, 0, 0);
                                          StoryBuilder.AppendRunScriptAction(segment, 90, "", "", "", true);
                                     	  segment.AppendToStory(no);
                                     	  StoryManager.PlayStory(client, no);
                                    }
                                    }
                                    }
                          else {
                          Story cancel = new Story();
                          StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          StoryBuilder.AppendSaySegment(segment, "You don't wanna swap? Meh-heh-heh... I get it!", Pokedex.FindByName("Croagunk").ID, 0, 0);
                          segment.AppendToStory(cancel);
                          StoryManager.PlayStory(client, cancel);
                          }
                        }
                        break;
                      case "Spiritomb": {
                      		if (answer == "Yes") {
                      			Messenger.SpellAnim(61, client.Player.MapID, client.Player.X, client.Player.Y);
                                MapNpcPreset npc = new MapNpcPreset();
                                npc.SpawnX = 10;
                                npc.SpawnY = 5;
                                npc.NpcNum = 1748;
                                npc.MinLevel = 30;
                                npc.MaxLevel = 30;
                                client.Player.Map.SpawnNpc(npc);
                                client.Player.TakeItem(251, 1);
                            }
                        }
                        break;
                    case "Candycane": {
                        if (answer == "Yes") {

                        } else if (answer == "Maybe later.") {
              						Story story = new Story();
                          		StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          		StoryBuilder.AppendSaySegment(segment, "Ah, okay! See you next time!", Pokedex.FindByName("Delibird").ID, 0, 0);
                          		segment.AppendToStory(story);
                          		StoryManager.PlayStory(client, story);

                        } else if (answer == "Ah, get lost.") {
                                Story story = new Story();
                          		StoryBuilderSegment segment = StoryBuilder.BuildStory();
                          		StoryBuilder.AppendSaySegment(segment, "...", Pokedex.FindByName("Delibird").ID, 0, 0);
                          		StoryBuilder.AppendSaySegment(segment, "Delibird will remember this.", -1, 0, 0);
                          		segment.AppendToStory(story);
                          		StoryManager.PlayStory(client, story);
                        }
                    }
                    break;

                    }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: QuestionResult" + ex.ToString(), Text.Black);
            }
        }
Beispiel #17
0
        public static void ScriptedTile(IMap map, ICharacter character, int script, string param1, string param2, string param3, PacketHitList hitlist)
        {
            try {
                PacketHitList.MethodStart(ref hitlist);
                Client client = null;
                if (character.CharacterType == Enums.CharacterType.Recruit) {
                    client = ((Recruit)character).Owner;
                }
                switch (script) {
                    case 0: {
                            if (character.CharacterType == Enums.CharacterType.Recruit) {
                                hitlist.AddPacket(((Recruit)character).Owner, PacketBuilder.CreateChatMsg("Empty Script", Text.Black));
                            }
                        }
                        break;
                    case 1: { // Story runner
                            if (exPlayer.Get(client).StoryEnabled) {
                                int storyNum = param1.ToInt() - 1;
                                if (client.Player.GetStoryState(storyNum) == false) {
                                    StoryManager.PlayStory(client, storyNum);
                                }
                            }
                        }
                        break;

                    case 2: {//Explosion trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on an Explosion Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 3: {//Chestnut Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Chestnut Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;

                    case 4: {//PP-Zero Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on an PP-Zero Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 5: {//Grimy Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Grimy Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;

                    case 6: {//Poison Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Poison Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 7: {//Random Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Random Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                                if (Server.Math.Rand(0, 10) + 6 < map.Tile[character.X, character.Y].Data2) {
                                    RemoveTrap(map, character.X, character.Y, hitlist);
                                }
                            }
                        }
                        break;
                    case 8: {//Appraisal;
                            if (client != null) {
                                int boxes = 0;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num != 0
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Type == Enums.ItemType.Scripted
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Data1 == 12
                                        && !client.Player.Inventory[i].Sticky) {
                                        boxes++;
                                    }
                                }
                                if (boxes > 0) {
                                    Messenger.AskQuestion(client, "Appraisal", "Will you have your boxes opened?  It will cost " + 150 * boxes + " Poké.", -1);
                                } else {
                                    Story story = new Story();
                                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                    StoryBuilder.AppendSaySegment(segment, "You can bring your treasure boxes here to have them opened for 150 Poké each.", -1, 0, 0);
                                    segment.AppendToStory(story);
                                    StoryManager.PlayStory(client, story);
                                }
                            }
                        }
                        break;
                    case 9: {//Un-sticky;
                            if (client != null) {
                                Messenger.AskQuestion(client, "Unsticky", "Will you have your sticky items cleansed?", -1);

                            }
                        }
                        break;
                    case 10: {//Full heal
                            if (client != null) {
                                for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                                    if (client.Player.Team[i].Loaded) { // Yes, there needs to be a check
                                        client.Player.Team[i].HP = client.Player.Team[i].MaxHP;
                                        client.Player.Team[i].RestoreBelly();
                                        client.Player.Team[i].StatusAilment = Enums.StatusAilment.OK;
                                        client.Player.Team[i].StatusAilmentCounter = 0;

                                        for (int j = 0; j < 4; j++) {
                                            if (client.Player.GetActiveRecruit().Moves[i].MoveNum != 0) {

                                                client.Player.Team[i].Moves[j].CurrentPP = client.Player.Team[i].Moves[j].MaxPP;
                                            }
                                        }
                                    }
                                }

                                hitlist.AddPacket(client, PacketBuilder.CreateBattleMsg("The entire party was fully healed!", Text.BrightGreen));
                                hitlist.AddPacket(client, PacketBuilder.CreateSoundPacket("magic25.wav"));
                                PacketBuilder.AppendPlayerMoves(client, hitlist);
                                PacketBuilder.AppendActiveTeamNum(client, hitlist);
                                PacketBuilder.AppendStatusAilment(client, hitlist);
                            }
                        }
                        break;

                    case 11: {//Warp out of Destiny Cavern
                            if (client != null) {
                                if (Settings.NewCharForm > 0) {
                                    //for (int i = 0; i < 4; i++) {

                                    client.Player.GetActiveRecruit().GenerateMoveset();
                                    client.Player.GetActiveRecruit().HP = client.Player.GetActiveRecruit().MaxHP;
                                    //if (client.Player.Team[i].Loaded) {//does there need to be a check for if the team member of the slot is there?
                                    //   client.Player.Team[i].HP = client.Player.Team[i].MaxHP;

                                    for (int j = 0; j < Constants.MAX_PLAYER_MOVES; j++) {
                                        if (client.Player.GetActiveRecruit().Moves[j].MoveNum != 0) {

                                            client.Player.GetActiveRecruit().Moves[j].CurrentPP = client.Player.GetActiveRecruit().Moves[j].MaxPP;
                                        }
                                    }
                                    //}
                                    //}
                                    //Messenger.PlayerWarp(client, 1, 10, 7);
                                    exPlayer.Get(client).SpawnMap = "s1035";
                                    exPlayer.Get(client).SpawnX = 9;
                                    exPlayer.Get(client).SpawnY = 7;
                                    StoryManager.PlayStory(client, 639);
                                    //StoryManager.PlayStory(client, 640);
                                    //} else {
                                    //	StoryManager.PlayStory(client, StoryConstruction.CreateIntroStory(client));
                                    //}
                                }
                            }
                        }
                        break;

                    case 12: {//Next floor of a different dungeon
                            if (client != null && map.MapType == Enums.MapType.RDungeonMap && ((RDungeonMap)map).RDungeonIndex > -1) {

                                PartyManager.AttemptPartyWarp(client, (Client warpClient) =>
                                {
                                    warpClient.Player.WarpToRDungeon(param1.ToInt() - 1, ((RDungeonMap)map).RDungeonFloor + 1);
                                });
                            }

                        }
                        break;

                    case 13: {//drop from the sky
                            if (client != null) {
                                Messenger.AskQuestion(client, "SkyDrop:" + param1 + ":" + param2, "Will you land at " + param3 + "?", -1);
                            }
                        }
                        break;
                    case 14: {//Fly
                            if (client != null) {
                                Messenger.PlayerMsg(client, "A strong updraft can be felt from here...", Text.Grey);
                                //Messenger.PlaySound(client, "Magic632.wav");
                                hitlist.AddPacket(client, PacketBuilder.CreateSoundPacket("Magic632.wav"));
                            }
                        }
                        break;
                    case 15: {// Warp Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Warp Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 16: {// Pokemon Trap (unfinished)
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Pokémon Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                                RemoveTrap(map, character.X, character.Y, hitlist);
                            }
                        }
                        break;
                    case 17: {// Spikes
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on the Spikes!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 18: {// Toxic spikes
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on the Toxic Spikes!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 19: { // Stealth Rock
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Stealth Rock Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 20: { // Void
                            if (client != null) {
                                if (Ranks.IsAllowed(client, Enums.Rank.Scripter)) {
                                    Messenger.PlayerWarpToVoid(client);
                                }
                            }
                        }
                        break;
                    case 21: {//completed level x dungeon
                            if (client != null) {
                                client.Player.EndTempStatMode();
                                exPlayer.Get(client).WarpToSpawn(false);
                            }
                        }
                        break;
                    case 22: {
                            //Anti-suicide; doesn't do anything here
                        }
                        break;
                    case 23: {//sticky trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Sticky Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 24: {//Admin-only
                            if (client != null) {
                                if (Ranks.IsDisallowed(client, Enums.Rank.Moniter)) {
                                    BlockPlayer(client);
                                    Messenger.PlayerMsg(client, "You must be an Admin to get through!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case 25: {//mud trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Mud Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                                if (Server.Math.Rand(0, 10) + 2 < map.Tile[character.X, character.Y].Data2) {
                                    RemoveTrap(map, character.X, character.Y, hitlist);
                                }
                            }
                        }
                        break;
                    case 26: {//wonder tile
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Wonder Tile!", Text.BrightGreen), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 27: {//activation
                            if (client != null) {
                                List<int> switches = new List<int>();
                                foreach (Client i in map.GetClients()) {
                                    if (i.Player.Map.Tile[i.Player.X, i.Player.Y].Type == Enums.TileType.Scripted
                                    && i.Player.Map.Tile[i.Player.X, i.Player.Y].Data1 == 27) {
                                        if (!switches.Contains(i.Player.Map.Tile[i.Player.X, i.Player.Y].Data2)) {
                                            switches.Add(i.Player.Map.Tile[i.Player.X, i.Player.Y].Data2);
                                        }
                                    }

                                }

                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a switch!", Text.BrightGreen), character.X, character.Y, 50);

                                if (switches.Count >= param1.ToInt()) {
                                    for (int x = 0; x < map.MaxX; x++) {
                                        for (int y = 0; y < map.MaxY; y++) {
                                            if (map.Tile[x, y].Type == Enums.TileType.RDungeonGoal) {
                                                map.Tile[x, y].Mask2Set = 4;
                                                map.Tile[x, y].Mask2 = 1;
                                                map.Tile[x, y].Data1 = 1;
                                                map.TempChange = true;
                                                hitlist.AddPacketToMap(map, PacketBuilder.CreateTilePacket(x, y, map));
                                            } else if (map.Tile[x, y].Type == Enums.TileType.Scripted && map.Tile[x, y].Data1 == 27) {
                                                map.Tile[x, y].Type = Enums.TileType.Walkable;
                                                map.Tile[x, y].Fringe = 0;
                                                map.Tile[x, y].FAnim = 0;
                                                hitlist.AddPacketToMap(map, PacketBuilder.CreateTilePacket(x, y, map));
                                            }
                                        }
                                    }
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("The passage to the next floor was opened!", Text.BrightGreen), character.X, character.Y, 50);
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic127.wav"), character.X, character.Y, 50);
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleDivider(), character.X, character.Y, 50);
                                } else if (param1.ToInt() - switches.Count == 1) {
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("1 more needs to be pressed at the same time...", Text.BrightGreen), character.X, character.Y, 50);
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic126.wav"), character.X, character.Y, 50);
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleDivider(), character.X, character.Y, 50);
                                } else {
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg((param1.ToInt() - switches.Count) + " more need to be pressed at the same time...", Text.BrightGreen), character.X, character.Y, 50);
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic126.wav"), character.X, character.Y, 50);
                                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleDivider(), character.X, character.Y, 50);
                                }
                            }
                        }
                        break;
                    case 28: {//Trip Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Trip Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 29: {//CTF Red Flag Tile
                            if (ActiveCTF.GameState == CTF.CTFGameState.Started) {
                                if (exPlayer.Get(client).InCTF) {
                                    if (exPlayer.Get(client).CTFSide != CTF.Teams.Red) {
                                        if (ActiveCTF.RedFlags > 0) {
                                            if (ActiveCTF.RedFlagHolder == null) {
                                                if (exPlayer.Get(client).CTFState == CTF.PlayerState.Free) {
                                                    exPlayer.Get(client).CTFState = CTF.PlayerState.HoldingFlag;
                                                    ActiveCTF.RedFlagHolder = client;
                                                    ActiveCTF.RedFlags--;
                                                    ActiveCTF.CTFMsg(client.Player.Name + " has stolen a red flag!", Text.Yellow);
                                                }
                                            } else {
                                                Messenger.PlayerMsg(client, ActiveCTF.RedFlagHolder.Player.Name + " is already holding a flag!", Text.Yellow);
                                            }
                                        } else {
                                            Messenger.PlayerMsg(client, "The red team has no more flags!", Text.Yellow);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case 30: {//CTF Blue Flag Tile
                            if (ActiveCTF.GameState == CTF.CTFGameState.Started) {
                                if (exPlayer.Get(client).InCTF && exPlayer.Get(client).CTFSide != CTF.Teams.Blue) {
                                    if (ActiveCTF.BlueFlags > 0) {
                                        if (ActiveCTF.BlueFlagHolder == null) {
                                            if (exPlayer.Get(client).CTFState == CTF.PlayerState.Free) {
                                                exPlayer.Get(client).CTFState = CTF.PlayerState.HoldingFlag;
                                                ActiveCTF.BlueFlagHolder = client;
                                                ActiveCTF.BlueFlags--;
                                                ActiveCTF.CTFMsg(client.Player.Name + " has stolen a blue flag!", Text.Yellow);
                                            }
                                        } else {
                                            Messenger.PlayerMsg(client, ActiveCTF.BlueFlagHolder.Player.Name + " is already holding a flag!", Text.Yellow);
                                        }
                                    } else {
                                        Messenger.PlayerMsg(client, "The blue team has no more flags!", Text.Yellow);
                                    }
                                }
                            }
                        }
                        break;
                    case 31: {//CTF Red Flag Check
                            if (ActiveCTF.GameState == CTF.CTFGameState.Started) {
                                ActiveCTF.CheckFlag(client, CTF.Teams.Blue);
                            }
                        }
                        break;
                    case 32: {//CTF Blue Flag Check
                            if (ActiveCTF.GameState == CTF.CTFGameState.Started) {
                                ActiveCTF.CheckFlag(client, CTF.Teams.Red);
                            }
                        }
                        break;
                    case 33: {//R Dungeon Goal for secret rooms; doesn't do anything here
                            client.Player.WarpToRDungeon(param1.ToInt() - 1, param2.ToInt() - 1);
                            //if (client.Player.Map.MapType == Enums.MapType.RDungeonMap && ((RDungeonMap)client.Player.Map).RDungeonIndex > -1) {
                            //	client.Player.WarpToDungeon(((RDungeonMap)client.Player.Map).RDungeonIndex, ((RDungeonMap)client.Player.Map).RDungeonFloor + 1);
                            //}
                        }
                        break;
                    case 34: {//Reveals stairs when stepped on
                            //if (client.Player.JobList.HasCompletedMission("dsksanasd984r487") == false) {
                            //    client.Player.JobList.AddJob("dsksanasd984r487");
                            //} else {
                            //    Messenger.PlayerMsg(client, "There are no special missions that you can play. Come back later!", Text.BrightRed);
                            //}
                            if (character.CharacterType != Enums.CharacterType.MapNpc) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                map.Tile[character.X, character.Y].Data1 = 35;
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("Stairs appeared!", Text.BrightRed), character.X, character.Y, 10);
                            }
                        }
                        break;
                    case 35: {//R Dungeon secret room
                            if (client != null && map.MapType == Enums.MapType.RDungeonMap && ((RDungeonMap)map).RDungeonIndex > -1) {

                                InstancedMap iMap = null;

                                PartyManager.AttemptPartyWarp(client, (Client warpClient) =>
                                {
                                    if (iMap == null) {
                                        iMap = new InstancedMap(MapManager.GenerateMapID("i"));
                                        IMap baseMap = MapManager.RetrieveMap(param1.ToInt());
                                        MapCloner.CloneMapTiles(baseMap, iMap);
                                        MapCloner.CloneMapNpcs(baseMap, iMap);
                                        MapCloner.CloneMapGeneralProperties(baseMap, iMap);
                                        iMap.MapBase = param1.ToInt();
                                        iMap.SpawnItems();
                                        for (int x = 0; x < iMap.MaxX; x++) {
                                            for (int y = 0; y < iMap.MaxY; y++) {
                                                if (iMap.Tile[x, y].Type == Enums.TileType.Scripted && iMap.Tile[x, y].Data1 == 33) {
                                                    //iMap.Tile[x, y].Data1 = 36;
                                                    iMap.Tile[x, y].String1 = (((RDungeonMap)map).RDungeonIndex + 1).ToString();
                                                    iMap.Tile[x, y].String2 = (((RDungeonMap)map).RDungeonFloor + 2).ToString();
                                                } else if (iMap.Tile[x, y].Type == Enums.TileType.Item) {
                                                    iMap.Tile[x, y].Type = Enums.TileType.Walkable;
                                                }
                                            }
                                        }
                                    }

                                    Messenger.PlayerWarp(warpClient, iMap, param2.ToInt(), param3.ToInt());
                                });

                            }
                        }
                        break;
                    case 36: {// Dungeon Entrance (Random)
                            if (client != null) {
                                //RDungeonManager.LoadRDungeon(param1.ToInt() - 1);
                                Story story = DungeonRules.CreatePreDungeonStory(client, param1, param2, param3, true);
                                StoryManager.PlayStory(client, story);

                                //if (param3 == "") {
                                //	Messenger.AskQuestion(client, "EnterRDungeon:" + (param1.ToInt() - 1) + ":" + (param2.ToInt() - 1) + ":" + param3, "Will you go on?", -1);
                                //} else if (param3.IsNumeric()) {
                                //	if (param3.ToInt() > 0) {
                                //normal dungeon, has dungeon entry
                                //		Messenger.AskQuestion(client, "EnterRDungeon:" + (param1.ToInt() - 1) + ":" + (param2.ToInt() - 1) + ":" + param3, "Will you enter " + DungeonManager.Dungeons[param3.ToInt() - 1].Name + "?", -1);
                                //	}
                                //} else {
                                //Event dungeon; does not have an official dungeon entry
                                //	Messenger.AskQuestion(client, "EnterRDungeon:" + (param1.ToInt() - 1) + ":" + (param2.ToInt() - 1) + ":" + param3, "Will you go enter " + param3 + "?", -1);
                                //}
                            }
                        }
                        break;
                    case 37: { // Dungeon Entrance (mapped)
                            if (client != null) {

                                Story story = DungeonRules.CreatePreDungeonStory(client, param1, param2, param3, false);
                                StoryManager.PlayStory(client, story);
                            }
                        }
                        break;
                    case 38: {// Housing Center
                            if (client != null) {
                                exPlayer.Get(client).HousingCenterMap = client.Player.MapID;
                                exPlayer.Get(client).HousingCenterX = client.Player.X;
                                exPlayer.Get(client).HousingCenterY = client.Player.Y;

                                Messenger.OpenVisitHouseMenu(client);
                            }
                        }
                        break;
                    case 39: { // Pitfall trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Pitfall Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 40: { // Evolution block tile
                            if (client != null) {
                                if (exPlayer.Get(client).EvolutionActive == false) {
                                    BlockPlayer(client);
                                    //    Messenger.PlayerMsg(client, "You can't enter this room!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case 41: { // Boss battle
                            if (client != null) {
                                //BossBattles.StartBossBattle(client, param1);
                            }
                        }
                        break;
                    case 42: { // Seal Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Seal Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 43: { // Slow Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Slow Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 44: { // Spin Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Spin Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 45: { // DungeonAttempted
                            if (client != null) {
                                int dungeonIndex = param1.ToInt();
                                int warpMap = param2.ToInt();
                                int warpX = param3.Split(':')[0].ToInt();
                                int warpY = param3.Split(':')[1].ToInt();
                                //Messenger.AskQuestion(client, "EnterDungeon:" + param1, "Will you enter " + DungeonManager.Dungeons[param1.ToInt()].Name + "?", -1);
                                client.Player.AddDungeonAttempt(dungeonIndex - 1);
                                Messenger.PlayerWarp(client, warpMap, warpX, warpY);
                            }
                        }
                        break;
                    case 46: {//Dungeon completion count incrementer
                            if (client != null) {

                                PartyManager.AttemptPartyWarp(client, (Client warpClient) =>
                                {
                                    int dungeonIndex = param1.ToInt();
                                    int warpMap = param2.ToInt();
                                    int warpX = param3.Split(':')[0].ToInt();
                                    int warpY = param3.Split(':')[1].ToInt();

                                    if (dungeonIndex > 0) {
                                        warpClient.Player.IncrementDungeonCompletionCount(dungeonIndex - 1, 1);
                                        PostDungeonCompletion(warpClient, dungeonIndex);
                                    }
                                    exPlayer.Get(warpClient).FirstMapLoaded = false;
                                    DungeonRules.ExitDungeon(warpClient, warpMap, warpX, warpY);
                                });

                            }
                        }
                        break;
                    case 47: {//Dungeon exit without increment

                        }
                        break;
                    case 48: { // Removes snowballs
                            if (client != null) {
                                if (client.Player.HasItem(152) > 0) {
                                    client.Player.TakeItem(152, 1);
                                }
                            }
                        }
                        break;
                    case 49: { // Sweet scent trap (summon)
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Summon Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                                RemoveTrap(map, character.X, character.Y, hitlist);
                            }
                        }
                        break;
                    case 50: { // GRUUUUUDGE Trap (Grudge)
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Grudge Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                                RemoveTrap(map, character.X, character.Y, hitlist);
                            }
                        }
                        break;
                    case 51: { // SelfDestruct Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Selfdestruct Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 52: { // Sleep Trap /slumber
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Slumber Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 53: { // Fan Trap /Gust
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Gust Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 54: { // Arena
                            if (client != null) {
                                bool canEnter = true;
                                for (int i = 1; i <= client.Player.MaxInv; i++) {
                                    if (client.Player.Inventory[i].Num > 0
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Type != Enums.ItemType.Held && ItemManager.Items[client.Player.Inventory[i].Num].Type != Enums.ItemType.HeldByParty
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Type != Enums.ItemType.HeldInBag) {
                                        bool held = false;

                                        for (int j = 0; j < Constants.MAX_ACTIVETEAM; j++) {
                                            if (client.Player.Team[j] != null
                                                && client.Player.Team[j].HeldItemSlot == i) {
                                                held = true;
                                            }

                                        }

                                        if (!held) canEnter = false;
                                    }
                                }

                                if (!canEnter) {
                                    Story story = new Story();
                                    StorySegment segment = new StorySegment();
                                    segment.Action = Enums.StoryAction.Say;
                                    segment.AddParameter("Text", "Notice:  You can only enter the arena with held-effect, team-effect, or bag-effect items.  Any other item must be held by a team member.");
                                    segment.AddParameter("Mugshot", "-1");
                                    segment.Parameters.Add("Speed", "0");
                                    segment.Parameters.Add("PauseLocation", "0");
                                    story.Segments.Add(segment);

                                    segment = new StorySegment();
                                    segment.Action = Enums.StoryAction.AskQuestion;
                                    segment.AddParameter("Question", "All items that do not fit arena restrictions will be sent to storage.  Is that OK?");
                                    segment.AddParameter("SegmentOnYes", (story.Segments.Count + 2).ToString());
                                    segment.AddParameter("SegmentOnNo", (story.Segments.Count + 3).ToString());
                                    segment.AddParameter("Mugshot", "-1");
                                    story.Segments.Add(segment);

                                    segment = new StorySegment();
                                    segment.Action = Enums.StoryAction.RunScript;
                                    segment.AddParameter("ScriptIndex", "61");
                                    segment.AddParameter("ScriptParam1", param1);
                                    segment.AddParameter("ScriptParam2", param2);
                                    segment.AddParameter("ScriptParam3", param3);
                                    segment.AddParameter("Pause", "1");
                                    story.Segments.Add(segment);

                                    StoryManager.PlayStory(client, story);

                                } else {
                                    EnterArena(client, character, map, param2, param3, hitlist);
                                }
                            }
                        }
                        break;
                    case 55: { // Staff Elevator
                            if (client != null) {
                                if (Ranks.IsAllowed(client, Enums.Rank.Moniter)) {
                                    // TODO: OpenStaffElevator(client);
                                }
                            }
                        }
                        break;
                    case 56: { // Pitch-Black Abyss warps
                            if (client != null) {
                                //if DungeonMap.Length < 1
                                //GenerateMap
                                /*Enums.Direction dir;
                                if (param1.ToInt() == 1) {
                                    dir = Enums.Direction.Up;
                                } else if (param1.ToInt() == 2) {
                                    dir = Enums.Direction.Down;
                                } else if (param1.ToInt() == 3) {
                                    dir = Enums.Direction.Left;
                                } else { //param1.ToInt() = 4
                                    dir = Enums.Direction.Right;
                                }*/
                                //switch to use dir when done rewriting GetDungeonRoom
                                if (exPlayer.Get(client).DungeonGenerated == false) {
                                    PitchBlackAbyss.GenerateMap(client);
                                }
                                PitchBlackAbyss.GetDungeonRoom(client, param1.ToInt());
                            }
                        }
                        break;
                    case 57: { // Pitch-Black Abyss entrance
                            if (client != null) {
                                if (client.Player.MapID == MapManager.GenerateMapID(1545)) { //easy PBA
                                    PitchBlackAbyss.InitializeMap(client, PitchBlackAbyss.Difficulty.Easy);
                                    PitchBlackAbyss.GenerateMap(client);
                                    Story story = DungeonRules.CreatePreDungeonStory(client, "1546", "9:9", "22", false);
                                    StoryManager.PlayStory(client, story);
                                }
                            }
                        }
                        break;
                    case 58: { // Electrostasis Tower Electrolock tile
                            if (client != null) {
                                ElectrostasisTower.SteppedOnElectrolock(client, param1.ToInt());
                            }
                        }
                        break;
                    case 59: { // Electrostasis Tower Sublevel Setter
                            if (client != null) {
                                string[] splitData = param2.Split(':');
                                ElectrostasisTower.SetSublevelCheckpoint(client, param1.ToInt(), splitData[0], splitData[1].ToInt(), splitData[2].ToInt());
                            }
                        }
                        break;
                    case 60: { // Warp to tournament hub
                            if (client != null) {
                                if (client.Player.Tournament != null) {
                                    client.Player.Tournament.WarpToHub(client);
                                }
                            }
                        }
                        break;
                    case 61: { // Warp to tournament combat map
                            if (client != null) {
                                if (client.Player.Tournament != null && client.Player.TournamentMatchUp != null) {
                                    client.Player.TournamentMatchUp.WarpToCombatMap(client);
                                }
                            }
                        }
                        break;
                    case 62: { // Open tournament spectator selection list
                            if (client != null) {
                                if (client.Player.Tournament == null) {
                                    Messenger.SendTournamentSpectateListingTo(client, null);
                                } else {
                                    client.Player.Tournament.WarpToHub(client);
                                }
                            }
                        }
                        break;
                    case 63: { // Leave tournament waiting room
                            if (client != null) {
                                if (client.Player.TournamentMatchUp == null) { // Prevent leaving if the player is in a match-up
                                    if (client.Player.Tournament != null) {
                                        client.Player.Tournament.RemoveRegisteredPlayer(client);
                                    }
                                    Messenger.PlayerWarp(client, 1192, 10, 10);
                                }
                            }
                        }
                        break;
                    case 64: {
                            if (exPlayer.Get(client).StoryEnabled) {
                                int[] rangeStart;
                                int[] rangeEnd;
                                string[] data1 = param1.Split('!');
                                string[] data2 = param2.Split(':');
                                rangeStart = new int[data1.Length];
                                rangeEnd = new int[data1.Length];
                                for (int i = 0; i < data1.Length; i++) {
                                    string[] vals = data1[i].Split(':');
                                    rangeStart[i] = vals[0].ToInt();
                                    rangeEnd[i] = vals[1].ToInt();
                                }
                                int currentStorySection = client.Player.StoryHelper.ReadSetting("[MainStory]-CurrentSection").ToInt();
                                for (int i = 0; i < rangeStart.Length; i++) {
                                    if (currentStorySection >= rangeStart[i] && currentStorySection <= rangeEnd[i]) {
                                        BlockPlayer(client);
                                        Messenger.PlayerMsg(client, data2[i], Text.BrightRed);
                                        break;
                                    }
                                }
                            }
                        }
                        break;
                    case 65: {//dungeon completion block
                            if (client != null) {
                                if (client.Player.GetDungeonCompletionCount(param1.ToInt() - 1) < 1) {
                                    BlockPlayer(client);
                                    Messenger.PlayerMsg(client, "You must complete " + DungeonManager.Dungeons[param1.ToInt() - 1].Name + " to get through!", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case 66: {// Delite Plaza exit warp
                            if (!string.IsNullOrEmpty(exPlayer.Get(client).PlazaEntranceMap)) {
                                Messenger.PlayerWarp(client, exPlayer.Get(client).PlazaEntranceMap, exPlayer.Get(client).PlazaEntranceX, exPlayer.Get(client).PlazaEntranceY);

                                exPlayer.Get(client).PlazaEntranceMap = null;
                                exPlayer.Get(client).PlazaEntranceX = 0;
                                exPlayer.Get(client).PlazaEntranceY = 0;
                            } else {
                                Messenger.PlayerWarp(client, 737, 6, 41);
                            }
                        }
                        break;
                    case 67: {// Auction master + bid winner only
                            if (client.Player.CharID != Auction.AuctionMaster && client.Player.CharID != Auction.LastAuctionMaster && client.Player.Name != Auction.HighestBidder
                                && Ranks.IsDisallowed(client, Enums.Rank.Moniter)) {
                                BlockPlayer(client);
                            }
                        }
                        break;
                    case 68: {// key-blocked next floor of different dungeon
                            if (client != null) {
                                int slot = 0;
                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num == param2.ToInt() && !client.Player.Inventory[i].Sticky) {
                                        slot = i;
                                        break;
                                    }
                                }
                                if (slot > 0) {
                                    Messenger.AskQuestion(client, "UseItem:" + param2, "Will you use your " + ItemManager.Items[param2.ToInt()].Name + " on this tile?", -1);
                                } else {
                                    Messenger.PlaySoundToMap(client.Player.MapID, "magic132.wav");
                                    //Messenger.PlayerMsg(client, Server.RDungeons.RDungeonManager.RDungeons[param1.ToInt()-1].DungeonName, Text.Pink);
                                    Messenger.PlayerMsg(client, "There is a peculiar marking on the floor... It seems to need a key.", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case 69: {// next floor of different dungeon
                            if (client != null) {

                                PartyManager.AttemptPartyWarp(client, (Client warpClient) =>
                                {
                                    warpClient.Player.WarpToRDungeon(param1.ToInt() - 1, ((RDungeonMap)warpClient.Player.Map).RDungeonFloor + 1);
                                });

                            }
                        }
                        break;
                    case 70: { // Shocker Trap
                            if (WillTrapActivate(character, map, character.X, character.Y)) {
                                RevealTrap(map, character.X, character.Y, hitlist);
                                hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " stepped on a Shocker Trap!", Text.BrightRed), character.X, character.Y, 10);
                                ActivateTrap(map, character.X, character.Y, script, hitlist);
                            }
                        }
                        break;
                    case 71: {// fossil revival
                            if (client != null) {
                                if (Server.Globals.ServerTime != Enums.Time.Night) {
                                    Story story = new Story();
                                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                    if (string.IsNullOrEmpty(param1)) {
                                        StoryBuilder.AppendSaySegment(segment, "The light of " + Server.Globals.ServerTime.ToString().ToLower() + " is seeping down from above.", -1, 0, 0);
                                    } else if (param1.ToInt() == 1) {
                                        StoryBuilder.AppendSaySegment(segment, "A bizzare light of " + Server.Globals.ServerTime.ToString().ToLower() + " is seeping down from above.", -1, 0, 0);
                                    }

                                    segment.AppendToStory(story);
                                    StoryManager.PlayStory(client, story);
                                } else {
                                    int slot = 0;
                                    int itemNum = -1;
                                    for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                        if (string.IsNullOrEmpty(param1)) {
                                            if (client.Player.Inventory[i].Num >= 791 && client.Player.Inventory[i].Num <= 799
                                                && !client.Player.Inventory[i].Sticky) {
                                                slot = i;
                                                itemNum = client.Player.Inventory[i].Num;
                                                break;
                                            }
                                        } else if (param1.ToInt() == 1) {
                                            if (client.Player.Inventory[i].Num == 846
                                                && !client.Player.Inventory[i].Sticky) {
                                                slot = i;
                                                itemNum = client.Player.Inventory[i].Num;
                                                break;
                                            }
                                        }
                                    }
                                    if (slot > 0) {
                                        if (string.IsNullOrEmpty(param1)) {
                                            Messenger.AskQuestion(client, "UseItem:" + itemNum, "Red moonlight is pouring down from above... Will you hold up your " + ItemManager.Items[itemNum].Name + " to the light?", -1);
                                        } else if (param1.ToInt() == 1) {
                                            Messenger.AskQuestion(client, "UseItem:" + itemNum, "Your Wonder Egg is emanating a strong aura. Will you hold up your " + ItemManager.Items[itemNum].Name + " to the light?", -1);
                                        }
                                        Messenger.PlaySoundToMap(client.Player.MapID, "magic848.wav");
                                    } else {

                                        Story story = new Story();
                                        StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                        if (string.IsNullOrEmpty(param1)) {
                                            StoryBuilder.AppendSaySegment(segment, "Red moonlight is pouring down from above...", -1, 0, 0);
                                        } else if (param1.ToInt() == 1) {
                                            StoryBuilder.AppendSaySegment(segment, "A bizzare light is seeping down from above...", -1, 0, 0);
                                        }
                                        segment.AppendToStory(story);
                                        StoryManager.PlayStory(client, story);

                                        Messenger.PlaySoundToMap(client.Player.MapID, "magic848.wav");
                                    }
                                }
                            }
                        }
                        break;
                    case 72: { // Warp to hard mode entrance
                            if (client != null) {
                                if (Ranks.IsAllowed(client, Enums.Rank.Moniter)) {
                                    Messenger.PlayerWarp(client, param1.ToInt(), param2.ToInt(), param3.ToInt());
                                }
                            }
                        }
                        break;
                    case 73: { // Warp from hard mode entrance
                            if (client != null) {
                                if (Ranks.IsAllowed(client, Enums.Rank.Moniter)) {
                                    Messenger.PlayerWarp(client, param1.ToInt(), param2.ToInt(), param3.ToInt());
                                }
                            }
                        }
                        break;
                    case 74: { // Tanren Arena
                            if (client != null) {
                                bool canEnter = true;
                                for (int i = 1; i <= client.Player.MaxInv; i++) {
                                    if (client.Player.Inventory[i].Num > 0
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Type != Enums.ItemType.Held && ItemManager.Items[client.Player.Inventory[i].Num].Type != Enums.ItemType.HeldByParty
                                        && ItemManager.Items[client.Player.Inventory[i].Num].Type != Enums.ItemType.HeldInBag) {
                                        bool held = false;

                                        for (int j = 0; j < Constants.MAX_ACTIVETEAM; j++) {
                                            if (client.Player.Team[j] != null
                                                && client.Player.Team[j].HeldItemSlot == i) {
                                                held = true;
                                            }

                                        }

                                        if (!held) canEnter = false;
                                    }
                                }

                                if (!canEnter) {
                                    Story story = new Story();
                                    StorySegment segment = new StorySegment();
                                    segment.Action = Enums.StoryAction.Say;
                                    segment.AddParameter("Text", "Notice:  You can only enter the arena with held-effect, team-effect, or bag-effect items.  Any other item must be held by a team member.");
                                    segment.AddParameter("Mugshot", "-1");
                                    segment.Parameters.Add("Speed", "0");
                                    segment.Parameters.Add("PauseLocation", "0");
                                    story.Segments.Add(segment);

                                    segment = new StorySegment();
                                    segment.Action = Enums.StoryAction.AskQuestion;
                                    segment.AddParameter("Question", "All items that do not fit arena restrictions will be sent to storage.  Is that OK?");
                                    segment.AddParameter("SegmentOnYes", (story.Segments.Count + 2).ToString());
                                    segment.AddParameter("SegmentOnNo", (story.Segments.Count + 3).ToString());
                                    segment.AddParameter("Mugshot", "-1");
                                    story.Segments.Add(segment);

                                    segment = new StorySegment();
                                    segment.Action = Enums.StoryAction.RunScript;
                                    segment.AddParameter("ScriptIndex", "61");
                                    segment.AddParameter("ScriptParam1", param1);
                                    segment.AddParameter("ScriptParam2", param2);
                                    segment.AddParameter("ScriptParam3", param3);
                                    segment.AddParameter("Pause", "1");
                                    story.Segments.Add(segment);

                                    StoryManager.PlayStory(client, story);

                                } else {
                                    client.Player.BeginTempStatMode(50, true);
                                    EnterArena(client, character, map, param2, param3, hitlist);
                                }
                            }
                        }
                        break;
                    case 75: {
                            for (int i = 1; i <= client.Player.MaxInv; i++) {
                                if (client.Player.Inventory[i].Num > -1) {
                                    BlockPlayer(client);
                                    Messenger.PlayerMsg(client, "You cannot have any items in your inventory!", Text.Red);
                                    break;
                                }
                            }

                            for (int j = 1; j < Constants.MAX_ACTIVETEAM; j++) {
                                if (client.Player.Team[j] != null) {
                                    BlockPlayer(client);
                                    Messenger.PlayerMsg(client, "You cannot have any team members in your team!", Text.Red);
                                    break;
                                }

                            }
                        }
                        break;
                    case 76: {//Dive
                            if (client != null) {
                                Messenger.PlayerMsg(client, "The water goes pretty deep here...", Text.Grey);
                                //Messenger.PlaySound(client, "Magic477.wav");
                                hitlist.AddPacket(client, PacketBuilder.CreateSoundPacket("Magic477.wav"));
                            }
                        }
                        break;
                    case 77: { // Asks a question
                            if (client != null) {
                                int slot = 0;
                                int itemNum = -1;
                                int npcToSpawn = param1.ToInt();
                                int itemToUse = param2.ToInt();
                                string questionAsked = param3;

                                for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                    if (client.Player.Inventory[i].Num == param2.ToInt()
                                        && !client.Player.Inventory[i].Sticky) {
                                        slot = i;
                                        itemNum = client.Player.Inventory[i].Num;
                                        break;
                                    }
                                }

                                if (slot > 0) {
                                    Messenger.AskQuestion(client, "UseItem:" + itemNum, param3, -1);
                                }
                            }
                        }
                        break;
                    case 78: {// warp everyone to respective locations
                            if (client != null) {

                                IMap sourceMap = client.Player.Map;
                                Tile clientTile = sourceMap.Tile[client.Player.X, client.Player.Y];
                                if (client.Player.PartyID == null) {
                                    Messenger.PlayerWarp(client, clientTile.String1.ToInt(), clientTile.String2.ToInt(), clientTile.String3.ToInt());
                                } else {
                                    bool warp = true;
                                    Party party = PartyManager.FindPlayerParty(client);
                                    foreach (Client member in party.GetOnlineMemberClients()) {
                                        Tile tile = sourceMap.Tile[member.Player.X, member.Player.Y];
                                        if (/*!member.Player.Dead &&*/ member.Player.MapID == client.Player.MapID && (clientTile.Type != tile.Type || clientTile.Data1 != tile.Data1 || clientTile.String1 != tile.String1)) {
                                            warp = false;
                                        }
                                    }

                                    if (warp) {
                                        foreach (Client member in party.GetOnlineMemberClients()) {
                                            if (member.Player.Map != sourceMap) continue;
                                            Tile tile = sourceMap.Tile[member.Player.X, member.Player.Y];
                                            Messenger.PlayerWarp(member, tile.String1.ToInt(), tile.String2.ToInt(), tile.String3.ToInt());
                                        }
                                    } else {
                                        Messenger.PlayerMsg(client, "All surviving players must be on the East or West stairs in order to continue.", Text.WhiteSmoke);
                                    }
                                }

                            }
                        }
                        break;
                }
                PacketHitList.MethodEnded(ref hitlist);
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: ScriptedTile", Text.Black);
                Messenger.AdminMsg(script + ", " + param1 + " " + param2 + " " + param3, Text.Black);
                Messenger.AdminMsg(map.Name, Text.Black);
                Messenger.AdminMsg(ex.ToString(), Text.Black);
            }
        }
Beispiel #18
0
        public static void ScriptedMissionWinDump(Client client)
        {
            try {
                int completedJobs = 0;

                Story story = new Story();
                StoryBuilderSegment segment = StoryBuilder.BuildStory();
                StoryBuilder.AppendWarpAction(segment, "s737", 39, 17);
                StoryBuilder.AppendPlayMusicAction(segment, "PMD2) Job Clear!.ogg", true, true);
                foreach (WonderMailJob mission in client.Player.JobList.JobList) {
                    if (mission.Accepted == Enums.JobStatus.Finished) {
                        completedJobs++;
                        MissionPool missionPool = WonderMailManager.Missions[(int)mission.Mission.Difficulty - 1];

                        StoryBuilder.AppendCreateFNPCAction(segment, "0", "s737", 39, 16, missionPool.MissionClients[mission.Mission.MissionClientIndex].Species);
                        StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Enums.Direction.Down);
                        if (mission.Mission.MissionType == Enums.MissionType.Escort) {
                            PokemonForm target = Pokedex.GetPokemonForm(mission.Mission.Data1, mission.Mission.Data1);
                            StoryBuilder.AppendCreateFNPCAction(segment, "1", "s737", 40, 16, missionPool.MissionClients[mission.Mission.MissionClientIndex].Species);
                            StoryBuilder.AppendChangeFNPCDirAction(segment, "1", Enums.Direction.Down);
                        }
                        if (mission.Mission.MissionType == Enums.MissionType.Escort) {
                            StoryBuilder.AppendSaySegment(segment, "Thank you for taking me to " + Pokedex.GetPokemon(mission.Mission.Data1).Name + "! Please accept our reward!", missionPool.MissionClients[mission.Mission.MissionClientIndex].Species, 0, 0);
                        } else if (mission.Mission.MissionType == Enums.MissionType.ItemRetrieval) {
                            StoryBuilder.AppendSaySegment(segment, "Thank you for the " + ItemManager.Items[mission.Mission.Data1].Name + "! Please accept this reward!", missionPool.MissionClients[mission.Mission.MissionClientIndex].Species, 0, 0);
                        } else if (mission.Mission.MissionType == Enums.MissionType.Rescue) {
                            StoryBuilder.AppendSaySegment(segment, "Thank you for rescuing me! Please accept this reward!", missionPool.MissionClients[mission.Mission.MissionClientIndex].Species, 0, 0);
                        }

                        //List<Server.WonderMails.MissionReward> rewards = Server.WonderMails.WonderMailSystem.RewardInfo[mission.WonderMail.RewardIndex].Rewards;
                        //for (int i = 0; i < rewards.Count; i++) {
                        //    StoryBuilder.AppendSaySegment(segment, "Obtained " + rewards[i].Amount + " " + ItemManager.Items[rewards[i].ItemNum].Name + "!", -1, 0, 0);
                        //}
                        if (ItemManager.Items[missionPool.Rewards[mission.Mission.RewardIndex].ItemNum].StackCap > 0) {
                            StoryBuilder.AppendSaySegment(segment, "Obtained " + missionPool.Rewards[mission.Mission.RewardIndex].Amount + " " + ItemManager.Items[missionPool.Rewards[mission.Mission.RewardIndex].ItemNum].Name + "!", -1, 0, 0);
                        } else {
                            StoryBuilder.AppendSaySegment(segment, "Obtained a " + ItemManager.Items[missionPool.Rewards[mission.Mission.RewardIndex].ItemNum].Name + "!", -1, 0, 0);
                        }
                        StoryBuilder.AppendMapVisibilityAction(segment, false);
                        StoryBuilder.AppendDeleteFNPCAction(segment, "0");
                        if (mission.Mission.MissionType == Enums.MissionType.Escort) {
                            StoryBuilder.AppendDeleteFNPCAction(segment, "1");
                        }
                        int expRewarded = MissionManager.DetermineMissionExpReward(mission.Mission.Difficulty);
                        //if (mission.WonderMail.MissionExp == -1) {
                        //    expRewarded = MissionManager.DetermineMissionExpReward(mission.WonderMail.Difficulty);
                        //} else {
                        //    expRewarded = mission.WonderMail.MissionExp;
                        //}
                        if (expRewarded > 0) {
                            StoryBuilder.AppendSaySegment(segment, "You have been awarded with " + expRewarded + " explorer points!", -1, 0, 0);
                        }
                        StoryBuilder.AppendPauseAction(segment, 1000);
                        StoryBuilder.AppendMapVisibilityAction(segment, true);
                    }
                }

                StoryBuilder.AppendPlayMusicAction(segment, "%mapmusic%", true, true);
                segment.AppendToStory(story);

                if (completedJobs > 0) {
                    StoryManager.PlayStory(client, story);
                }

            } catch (Exception ex) {
                Messenger.AdminMsg("Error: ScriptedMissionWinDump", Text.Black);
            }
        }
Beispiel #19
0
        public static Story CreateIntroStory(Client client)
        {
            Story story = new Story();

            StoryBuilderSegment segment = new StoryBuilderSegment();

            Pokemon eevee = Pokedex.FindByName("Eevee");
            string map1ID = Main.Crossroads;

            StoryBuilder.AppendMapVisibilityAction(segment, false);
            StoryBuilder.AppendPlayerPadlockAction(segment, "Lock");
            StoryBuilder.AppendWarpAction(segment, map1ID, 25, 25);
            StoryBuilder.AppendPlayMusicAction(segment, "PMD2) Strange Happenings.mp3", true, true);
            StoryBuilder.AppendSaySegment(segment, "You step into the light of the crystal...", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "You feel its energy going through your body...", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "Dizzy... are you moving?", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "You feel a cool breeze... maybe, just maybe...", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "You slowly open your eyes...", -1, 0, 0);
            StoryBuilder.AppendPauseAction(segment, 1000);
            StoryBuilder.AppendPlayMusicAction(segment, "%mapmusic%", true, true);
            StoryBuilder.AppendSaySegment(segment, "Hey! You!", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "Are you okay?", -1, 0, 0);
            StoryBuilder.AppendCreateFNPCAction(segment, "0", map1ID, 25, 23, eevee.ID);
            StoryBuilder.AppendChangeFNPCDirAction(segment, "0", Server.Enums.Direction.Down);
            StoryBuilder.AppendMapVisibilityAction(segment, true);
            StoryBuilder.AppendSaySegment(segment, "Oh, good! You're awake!", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "You've been laying there for a while now. Are you okay? Are you hurt?", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "(An eevee is talking to me...)", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "Oh, well. The important thing is that you are awake now!", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "So, where are you from? I haven't seen you in these parts before.", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "(Hmm... Where am I from? I don't remember a thing)", -1, 0, 0);
            StoryBuilder.AppendPauseAction(segment, 1000);
            StoryBuilder.AppendSaySegment(segment, "Oh, you don't remember? Strange. Anyway, you're probably wondering who I am...", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "...I am the great Eevocious! Master of evolutions and battle!", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "(Eevocious, huh... what an odd name. But, alright. Eevocious it is.)", -1, 0, 0);
            StoryBuilder.AppendPauseAction(segment, 2000);
            StoryBuilder.AppendSaySegment(segment, "...I bet I fooled you, didn't I.", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "And you actually thought I was Eevocious!", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "Yeah, I'm sorry. It's just hard to resist. A new Pokemon just appearing out of no where gives me a chance to be whomever I want to be!", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "(Very funny)", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "Anyway, my real name is Eevee. I'm an explorer. Or, I want to become an explorer. See...", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "I can't become a true explorer until I prove that I am capable of handling the toughest situations. That's why I'm training to be able to get through Tiny Grotto!", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "(Tiny Grotto?)", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "You're probably wondering what Tiny Grotto even is! I'll explain.", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "It's a dungeon. It's not the hardest dungeon, but it's good practice. Yup, so I'm going to Tiny Grotto!", eevee.ID, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "(Oh look, Eevee is leaving me.)", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "Bye~!", eevee.ID, 0, 0);
            StoryBuilder.AppendMoveFNPCAction(segment, "0", 1, 24, Server.Enums.Speed.Walking, true);
            StoryBuilder.AppendDeleteFNPCAction(segment, "0");
            StoryBuilder.AppendSaySegment(segment, "(Now what do I do next? I know I can't go to Tiny Grotto... I don't even know how to battle!)", -1, 0, 0);
            StoryBuilder.AppendSaySegment(segment, "(Maybe I'll find out more if I continue going North (^))", -1, 0, 0);
            StoryBuilder.AppendPlayerPadlockAction(segment, "Unlock");

            if (client.Player.Veteran) {
                StoryBuilder.AppendPlayerPadlockAction(segment, "Lock");
                StoryBuilder.AppendPauseAction(segment, 2000);
                StoryBuilder.AppendSaySegment(segment, "Pikablu: Cool! Eevee is back!", -1, 0, 0);
                StoryBuilder.AppendSaySegment(segment, "Pikablu: Have fun exploring!", -1, 0, 0);
                StoryBuilder.AppendPlayerPadlockAction(segment, "Unlock");
            }
            #region old
            //StoryBuilder.AppendMapVisibilityAction(segment, false);
            //StoryBuilder.AppendSaySegment(segment, "Hey! You!", -1, 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "Are you okay?", -1, 0, 0);
            //StoryBuilder.AppendCreateFNPCAction(segment, "0", map1ID, 10, 6, eevee.Sprite);
            //StoryBuilder.AppendMapVisibilityAction(segment, true);
            //StoryBuilder.AppendSaySegment(segment, "Oh, good! You're awake!", eevee.Mugshot, 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "You've been laying there for a while now. Are you okay? Are you hurt?", eevee.Mugshot, 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "(An eevee is talking to me...)", -1, 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "You're probably wondering what Tiny Woods even is! I'll explain.", eevee.Mugshot , 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "It's a dungeon. It's not the hardest dungeon, but it's good practice. Yup, so I'm going to Tiny Woods!", eevee.Mugshot, 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "(Oh look, Eevee is leaving me. Fun.", -1, 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "Bye~!", eevee.Mugshot , 0, 0);
            //StoryBuilder.AppendMoveFNPCAction(segment, "0", 0, 7, Server.Enums.Speed.Walking, true);
            //StoryBuilder.AppendDeleteFNPCAction(segment, "0");
            //StoryBuilder.AppendSaySegment(segment, "(Now what do I do next? I know I can't go to Tiny Woods... I don't even know how to battle!", -1, 0, 0);
            //StoryBuilder.AppendSaySegment(segment, "(Maybe I'll find out more if I continue going North (^))", -1, 0, 0);
            //StoryBuilder.AppendPlayerPadlockAction(segment, "Unlock");
            #endregion

            segment.AppendToStory(story);
            return story;
        }
Beispiel #20
0
        public static void ScriptedSign(Client client, int script, string string1, string string2, string string3, Enums.Direction dir)
        {
            try {
                switch (script) {
                    case 0: {
                            //Messenger.PlayerMsg(index, "High scores for: Pit of 100 Trials", Text.Black);
                            //for (int i = 0; i < 10; i++) {
                            //    int scoreFloor = ((CXmlEditor)ObjectFactory.GetObject("pitof100trialsscores")).TryGetAttributeValue("score" + i.ToString(), "Scores", "floor").ToInt(-1);
                            //    if (scoreFloor > -1) {
                            //        NetScript.PlayerMsg(index, (i + 1).ToString() + ". Player: " + ((CXmlEditor)ObjectFactory.GetObject("pitof100trialsscores")).TryGetAttributeValue("score" + i.ToString(), "Scores", "player") + ", Floor: " + (scoreFloor + 1).ToString(), Text.Grey);
                            //    } else {
                            //        NetScript.PlayerMsg(index, (i + 1).ToString() + ". No score registered.", Text.Grey);
                            //    }
                            //}
                        }
                        break;
                    case 1: {
                            if (dir == Enums.Direction.Up) {
                                Messenger.PlayerMsg(client, "Read the back of this sign to win a prize!", Text.Yellow);
                            } else if (dir == Enums.Direction.Down) {
                                Messenger.PlayerMsg(client, "Read the front of this sign to learn how to win a prize!", Text.Yellow);
                            } else if (dir == Enums.Direction.Left) {
                                Messenger.PlayerMsg(client, "You didn't even think to read the sign from the right? WELL YOU SHOULD NEXT TIME", Text.Yellow);
                            } else {
                                Messenger.PlayerMsg(client, "Of course, reading this sign from the left is the way to go.", Text.Yellow);
                            }
                        }
                        break;
                    case 2: {
                            IMap map = client.Player.Map;
                            if (dir == Enums.Direction.Up) {
                                if (map.Tile[client.Player.X, client.Player.Y - 2].Type == Enums.TileType.Walkable) {
                                    client.Player.Y -= 2;
                                    //Messenger.SendPlayerXY(client);
                                    Messenger.PlaySoundToMap(client.Player.MapID, "magic19.wav");
                                } else {
                                    Messenger.PlayerMsg(client, "You can't jump here!", Text.BrightRed);
                                }
                            } else if (dir == Enums.Direction.Down) {
                                if (map.Tile[client.Player.X, client.Player.Y + 2].Type == Enums.TileType.Walkable) {
                                    client.Player.Y += 2;
                                    //Messenger.SendPlayerXY(client);
                                    Messenger.PlaySoundToMap(client.Player.MapID, "magic19.wav");
                                } else {
                                    Messenger.PlayerMsg(client, "You can't jump here!", Text.BrightRed);
                                }
                            } else if (dir == Enums.Direction.Left) {
                                if (map.Tile[client.Player.X - 2, client.Player.Y].Type == Enums.TileType.Walkable) {
                                    client.Player.X -= 2;
                                    //Messenger.SendPlayerXY(client);
                                    Messenger.PlaySoundToMap(client.Player.MapID, "magic19.wav");
                                } else {
                                    Messenger.PlayerMsg(client, "You can't jump here!", Text.BrightRed);
                                }
                            } else {
                                if (map.Tile[client.Player.X + 2, client.Player.Y].Type == Enums.TileType.Walkable) {
                                    client.Player.X += 2;
                                    //Messenger.SendPlayerXY(client);
                                    Messenger.PlaySoundToMap(client.Player.MapID, "magic19.wav");
                                } else {
                                    Messenger.PlayerMsg(client, "You can't jump here!", Text.BrightRed);
                                }
                            }

                        }
                        break;
                    case 3: {
                            StoryManager.PlayStory(client, 36);
                        }
                        break;
                    case 4: {//FFF warp
                            if (client.Player.GetDungeonCompletionCount(5) == 0) {
                                StoryManager.PlayStory(client, 157);
                            } else {
                                StoryManager.PlayStory(client, 158);
                            }
                        }
                        break;
                    case 5: {// Lottery Board
                            if (dir == Enums.Direction.Up) {
                                if (DateTime.Now.DayOfWeek != Lottery.LOTTERY_DAY) {
                                    if (client.Player.HasItem(1) >= 25) {
                                        //if (DateTime.Now.DayOfWeek != LOTTERY_DAY) {
                                        //    NetScript.PlayerMsg(index, "Remember: There is no draw today. Come back on " + LOTTERY_DAY.ToString() + " to enter in the draw!", Text.Grey);
                                        //}
                                        Messenger.AskQuestion(client, "buylotteryticket", "Would you like to purchase one lottery ticket for 25 Poké?", -1);
                                    } else {
                                        //NetScript.PlayerMsg(index, "There is no draw today. Come back on " + LOTTERY_DAY.ToString(), Text.BrightRed);
                                        Messenger.PlayerMsg(client, "You don't have enough money to buy a lottery ticket!", Text.BrightRed);
                                    }
                                } else if (client.Player.HasItem(381) > 0) {
                                    Messenger.AskQuestion(client, "uselotteryticket", "Would you like to use your lottery ticket?", -1);
                                    //} else if (ObjectFactory.GetPlayer(index).HasItem(1) >= 25) {
                                    //    NetScript.AskQuestion(index, "buylotteryticket", "Would you like to purchase one lottery ticket for 25 Poké?", -1);
                                } else {
                                    Messenger.PlayerMsg(client, "Come back tomorrow to purchase next week's lottery tickets.", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case 6: {//for rock climb
                            Messenger.PlayerMsg(client, "This wall is very rocky... perhaps there is some way to scale it?", Text.Grey);
                        }
                        break;
                    case 7: {//for waterfall
                            Messenger.PlayerMsg(client, "A waterfall crashes down with a mighty roar...", Text.Grey);
                        }
                        break;
                    case 8: {//for west wing
                            if (client.Player.HasItem(249) > 0) {
                                Messenger.AskQuestion(client, "AbandonedMansion", "Will you use the West Wing Key?", -1);
                            } else {
                                StoryManager.PlayStory(client, 298);
                            }
                        }
                        break;
                    case 9: {//chamber tile; doesn't do anything here

                        }
                        break;
                    case 10: {//chamber key
                            int slot = 0;
                            for (int i = 1; i <= client.Player.Inventory.Count; i++) {
                                if (client.Player.Inventory[i].Num == 356 && !client.Player.Inventory[i].Sticky) {
                                    slot = i;
                                    break;
                                }
                            }
                            if (slot > 0) {
                                Messenger.AskQuestion(client, "UseItem:356", "Will you use your Silver Key to open the chamber?", -1);
                            }
                        }
                        break;
                    case 11: {//secret room
                            if (client.Player.HasItem(250) > 0) {
                                StoryManager.PlayStory(client, 299);
                            } else {
                                StoryManager.PlayStory(client, 300);
                            }
                        }
                        break;
                    case 12: {//Hallowed Well

                                Story story = new Story();
                                StorySegment segment = new StorySegment();
                                segment.Action = Enums.StoryAction.Say;
                                segment.AddParameter("Text", "This well makes you feel uneasy...  It's feels as though it wants to suck you in...");
                                segment.AddParameter("Mugshot", "-1");
                                segment.Parameters.Add("Speed", "0");
                                segment.Parameters.Add("PauseLocation", "0");
                                story.Segments.Add(segment);

                                segment = new StorySegment();
                                segment.Action = Enums.StoryAction.Say;
                                segment.AddParameter("Text", "Something shiny seems to glint from the bottom...");
                                segment.AddParameter("Mugshot", "-1");
                                segment.Parameters.Add("Speed", "0");
                                segment.Parameters.Add("PauseLocation", "0");
                                story.Segments.Add(segment);

                        StoryManager.PlayStory(client, story);

                            //Messenger.AskQuestion(client, "HallowedWell", "Will you jump into the well?", -1);
                        }
                        break;
                    case 13: {//for the Dive Whirlpool itself
                            Messenger.PlayerMsg(client, "A powerful whirlpool is pulling pulling everything into the depths...", Text.Grey);
                        }
                        break;
                    case 14: {
                            Messenger.AskQuestion(client, "CliffsideTablet", "Will you rip one of the tablets off the wall?", -1);
                        }
                        break;
                    case 15: {
                            if (client.Player.HasItem(479) > 0) {
                                StoryManager.PlayStory(client, 121);
                            } else {
                                StoryManager.PlayStory(client, 120);
                            }
                        }
                        break;
                    case 16: { // Register for tournament
                            if (client.Player.Tournament == null) {
                                if (TournamentManager.Tournaments.Count > 0) {
                                    Story story = new Story();
                                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                    StoryBuilder.AppendSaySegment(segment, "Hello! I can help you join a tournament!", -1, 0, 0);
                                    StoryBuilder.AppendAskQuestionAction(segment, "Would you like to join a tournament?", 3, 5, -1);
                                    // "Yes" section
                                    StoryBuilder.AppendRunScriptAction(segment, 55, "", "", "", true);
                                    StoryBuilder.AppendGoToSegmentAction(segment, 6);
                                    // "No" section
                                    StoryBuilder.AppendSaySegment(segment, "Come back if you want to join a tournament!", -1, 0, 0);
                                    StoryBuilder.AppendPauseAction(segment, 1);

                                    segment.AppendToStory(story);
                                    StoryManager.PlayStory(client, story);
                                } else {
                                    Story story = new Story();
                                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                                    StoryBuilder.AppendSaySegment(segment, "Sorry! No tournaments have been created yet! Come back when one has been made!", -1, 0, 0);

                                    segment.AppendToStory(story);
                                    StoryManager.PlayStory(client, story);
                                }
                            }
                        }
                        break;
                    case 17: {
                            int surfSlot = -1;
                            for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                                if (client.Player.GetActiveRecruit().Moves[i].MoveNum == 462) {
                                    surfSlot = i;
                                }
                            }

                            if (surfSlot > -1) {
                                Messenger.AskQuestion(client, "Surf", "Water currents lead into the distance... Would you like to use Surf?", -1);
                            }

                        }
                        break;
                    case 18: { // Start the tournament
                            if (client.Player.Tournament != null) {
                                Tournament tourny = client.Player.Tournament;
                                if (tourny.RegisteredMembers[client].Admin) {
                                    Messenger.AskQuestion(client, "TournamentAdminOptions", "What would you like to do?", -1, new string[] { "Start Tournament", "Edit Rules" });
                                }
                            }
                        }
                        break;
                    case 19: {
                            //if (client.Player.HasItem(479) > 0) {
                            StoryManager.PlayStory(client, 184);
                            //} else {
                            //    StoryManager.PlayStory(client, 120);
                            //}
                        }
                        break;
                    case 20: {
                            int surfSlot = -1;
                            for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                                if (client.Player.GetActiveRecruit().Moves[i].MoveNum == 456) {
                                    surfSlot = i;
                                }
                            }

                            if (surfSlot > -1) {
                                Messenger.AskQuestion(client, "RockClimb", "This wall is very rocky.  Would you like to use Rock Climb?", -1);
                            }

                        }
                        break;
                    case 21: {
                            if (SnowballGame.IsGameOwner(client) == false) {
                                string waitingGameOwner = SnowballGame.FindWaitingGame();
                                if (string.IsNullOrEmpty(waitingGameOwner)) {
                                    // There are no games waiting to start
                                    Messenger.AskQuestion(client, "SnowballGameNewGame", "Would you like to create a new game?", -1);
                                } else {
                                    // There is a game waiting to start! Join in!
                                    Messenger.AskQuestion(client, "SnowballGameJoinGame", "Would you like to join the game?", -1);
                                }
                            } else {
                                Messenger.AskQuestion(client, "SnowballGameStart", "Would you like to start the game with these players?", -1);
                            }
                        }
                        break;

                }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: ScriptedSign", Text.Black);
            }
        }
Beispiel #21
0
        public static void IncubateEgg(Client client, int itemNum)
        {
            //works on the condition that the player has at least 1 slot open,
            //the map is a safe zone

            InventoryItem item = client.Player.Inventory[itemNum];
            string[] eggArgs = item.Tag.Split(';');
            //Messenger.PlayerMsg(client, eggArgs[1], Text.Black);
            if (item.Num == 110) {
                item.Num = 109;
                item.Tag = eggArgs[0] + ";60";
                Messenger.SendInventoryUpdate(client, itemNum);
                Messenger.PlaySoundToMap(client.Player.MapID, "magic852.wav");
            } else if (item.Num == 109) {
                item.Num = 131;
                item.Tag = eggArgs[0] + ";15";
                Messenger.SendInventoryUpdate(client, itemNum);
                Messenger.PlaySoundToMap(client.Player.MapID, "magic852.wav");
            } else if (item.Num == 131) {
                if (client.Player.FindOpenTeamSlot() > -1 &&
                    (client.Player.Map.Moral == Enums.MapMoral.Safe || client.Player.Map.Moral == Enums.MapMoral.House)) {
                    item.Tag = eggArgs[0] + ";0";
                    string[] hatchedArgs = eggArgs[0].Split(',');
                    int recruit = hatchedArgs[0].ToInt(-1);

                    if (recruit < 0) recruit = 1;

                    Story story = new Story();
                    StoryBuilderSegment segment = StoryBuilder.BuildStory();
                    StoryBuilder.AppendPlayerPadlockAction(segment, "Lock");
                    StoryBuilder.AppendSaySegment(segment, "Oh?", -1, 0, 0);
                    StoryBuilder.AppendSaySegment(segment, "The Mystery Egg is hatching!", -1, 0, 0);
                    StoryBuilder.AppendPlayMusicAction(segment, "PMD) Awakening.ogg", true, false);
                    StoryBuilder.AppendSaySegment(segment, "It's a healthy " + Pokedex.GetPokemon(recruit).Name + "!", recruit, 0, 0);
                    StoryBuilder.AppendAskQuestionAction(segment, "Will you accept the newly hatched " + Pokedex.GetPokemon(recruit).Name + " into your team?", 7, 9, recruit);
                    StoryBuilder.AppendRunScriptAction(segment, 47, "", "", "", true);
                    StoryBuilder.AppendGoToSegmentAction(segment, 10);
                    StoryBuilder.AppendSaySegment(segment, "The " + Pokedex.GetPokemon(recruit).Name + " left to live a carefree life without the team.", -1, 0, 0);
                    StoryBuilder.AppendRunScriptAction(segment, 49, "", "", "", true);
                    StoryBuilder.AppendPlayerPadlockAction(segment, "Unlock");

                    segment.AppendToStory(story);

                    Messenger.PlaySoundToMap(client.Player.MapID, "magic41.wav");
                    StoryManager.PlayStory(client, story);
                }
            }
        }
Beispiel #22
0
        internal static void ProcessData(Client client, string[] parse)
        {
            //string[] parse = data.Split(TcpPacket.SEP_CHAR);
            if (client.Player == null)
            {
                if (parse[0].ToLower() == "requestnews")
                {
                    Messenger.SendNews(client);
                    client.InitializeClientSystem();
                    return;
                }
            }
            if (client.Player == null)
            {
                Messenger.PlainMsg(client, "Unable to initialize connection. Please retry.", Enums.PlainMsgType.MainMenu);
                return;
            }
            if (!client.Player.LoggedIn)
            {
                #region Not Logged In
                switch (parse[0].ToLower())
                {
                    case "clienterror":
                        {
                            string error = parse[1];
                            error += "\r\n\r\n------- ERROR REPORT END -------\r\n\r\n";
                            Logging.Logger.AppendToLog("/Client Error Logs/" + DateTime.Now.ToShortDateString().Replace("/", "-") + "/log.txt", error);
                        }
                        break;
                    case "requestnews":
                        Messenger.SendNews(client);
                        client.InitializeClientSystem();
                        break;
                    #region Logging In
                    case "login":
                        {
                            if (Globals.ServerClosed)
                            {
                                Messenger.PlainMsg(client, "Server is closed at the moment!", Enums.PlainMsgType.MainMenu);
                                return;
                            }
                            if (ClientManager.CanLogin(parse[1]))
                            {
                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    // Check if the account exists
                                    if (PlayerManager.AccountExists(dbConnection, parse[1]) == false)
                                    {
                                        Messenger.PlainMsg(client, "This account does not exist.", Enums.PlainMsgType.MainMenu);
                                        return;
                                    }
                                    // Check the client version
                                    if (parse[3].ToInt() < Constants.CLIENT_VERSION)
                                    {
                                        Messenger.PlainMsg(client, "Your client is outdated. Please update your client.", Enums.PlainMsgType.MainMenu);
                                        return;
                                    }
                                    // Verify that the client used is a valid one
                                    if (parse[10] != "PMDCPCore")
                                    {
                                        Messenger.PlainMsg(client, "Bad client version! Did you edit the source code?", Enums.PlainMsgType.MainMenu);
                                        return;
                                    }

            #if !DEBUG
                                    if (ClientManager.IsMacAddressConnected(parse[11])) {
                                        Messenger.PlainMsg(client, "You are already playing on this computer!", Enums.PlainMsgType.MainMenu);
                                        return;
                                    }

            #endif

                                    string password = Security.Hash.GenerateMD5Hash(parse[2]).Trim();
                                    if (PlayerManager.IsPasswordCorrect(dbConnection, parse[1], password))
                                    {

                                        client.SetMacAddress(parse[11]);
                                        client.SetBiosIdentification(parse[12]);
                                        // Check if they aren't banned
                                        if (Bans.IsIPBanned(dbConnection, client) == Enums.BanType.Ban || Bans.IsMacBanned(dbConnection, client) == Enums.BanType.Ban)
                                        {
                                            Logging.ChatLogger.AppendToChatLog("Staff", "IP: " + client.IP + " Mac: " + client.MacAddress + " attempted to log on, but was banned.");
                                            Messenger.PlainMsg(client, "You can't enter this world!", Enums.PlainMsgType.MainMenu);
                                            client.SetMacAddress("");
                                            client.SetBiosIdentification("");
                                            return;
                                        }

                                        client.Player.AccountName = parse[1];

                                        client.Player.SetSystemInfo(parse[8], parse[9], parse[10]);
                                        Messenger.SendChars(dbConnection, client);
                                    }
                                    else
                                    {
                                        Messenger.PlainMsg(client, "Invalid password.", Enums.PlainMsgType.MainMenu);
                                    }
                                }
                            }
                            else
                            {
                                Messenger.PlainMsg(client, "You are already in the Pokémon world!", Enums.PlainMsgType.MainMenu);
                            }
                        }
                        break;
                    case "charlistrequest":
                        {
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                Messenger.SendChars(dbConnection, client);
                            }
                        }
                        break;
                    case "usechar":
                        {
                            int charNum = parse[1].ToInt();
                            if (charNum < 1 || charNum > 3)
                                return;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                if (client.Player.CharacterExists(dbConnection, charNum))
                                {
                                    client.Player.LoadCharacter(dbConnection, parse[1].ToInt(1));
                                    if (Globals.GMOnly)
                                    {
                                        if (client.Player.Access == Enums.Rank.Normal)
                                        {
                                            Messenger.PlainMsg(client, "The server is only open to GMs at the moment!", Enums.PlainMsgType.MainMenu);
                                            client.CloseConnection();
                                            //PlayerManager.Players.RemovePlayer(client);
                                            //PlayerManager.Players.AddPlayer(client);
                                            return;
                                        }
                                    }

                                    if (ClientManager.IsCharacterLoggedIn(client.Player.CharID))
                                    {
                                        Messenger.PlainMsg(client, "You are already playing on this computer!", Enums.PlainMsgType.MainMenu);
                                        return;
                                    }

                                    if (Bans.IsCharacterBanned(dbConnection, client.Player.CharID) == Enums.BanType.Ban)
                                    {
                                        Messenger.PlainMsg(client, "This character can't enter the Pokémon world!", Enums.PlainMsgType.MainMenu);
                                        client.Player = new Player(client);
                                        client.CloseConnection();
                                        return;
                                    }

                                    client.Player.Statistics.HandleLogin(client.Player.GetOSVersion(), client.Player.GetDotNetVersion(), client.MacAddress, client.IP);

                                    Messenger.SendJoinGame(client);

                                    //Globals.ServerUI.AddLog(PlayerManager.Players.GetPlayer(client).mLogin + "/" + PlayerManager.Players.GetPlayer(client).mName + " has started playing!");
                                }
                                else
                                {
                                    Messenger.PlainMsg(client, "This character hasn't been sent to the Pokémon world yet!", Enums.PlainMsgType.Chars);
                                    return;
                                }
                            }
                        }
                        break;
                    #endregion
                    #region Account Editing
                    case "gatglasses":
                        {//typo?  then again, we don't need classes...
                            Messenger.SendNewCharClasses(client);
                        }
                        break;
                    case "createaccount":
                        {
                            if (client.Player.LoggedIn == false)
                            {
                                string name = parse[1];
                                string password = parse[2];
                                string email = parse[3];

                                for (int i = 0; i < name.Length; i++)
                                {
                                    int n = (int)Convert.ToChar(name.Substring(i, 1));

                                    if (n == 32 && (i == 0 || i == name.Length - 1))
                                    {
                                        Messenger.PlainMsg(client, "Names cannot begin or end with spaces.", Enums.PlainMsgType.NewAccount);
                                        return;
                                    }

                                    if ((n >= 65 & n <= 90) | (n >= 97 & n <= 122) | (n == 95) | (n == 32) | (n >= 48 & n <= 57))
                                    {
                                    }
                                    else
                                    {
                                        Messenger.PlainMsg(client, "Invalid name, only letters, numbers, spaces, and _ allowed in names.", Enums.PlainMsgType.NewAccount);
                                        return;
                                    }
                                }

                                if (name.Length < 3 || name.Length > 24)
                                {
                                    Messenger.PlainMsg(client, "Name must be between 3 and 24 letters long.", Enums.PlainMsgType.NewAccount);
                                    return;
                                }

                                // TODO: Add email support to account creation [HIGH]
                                //if (Email.Email.IsValidEmail(email) == false) {
                                //    Messenger.PlainMsg(client, "Invalid email.", Enums.PlainMsgType.NewAccount);
                                //    return;
                                //}

                                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                {
                                    int result = PlayerManager.CreateNewAccount(dbConnection, name, password, "");
                                    if (result == -1)
                                    {
                                        Messenger.PlainMsg(client, "An error occurred while creating your account.", Enums.PlainMsgType.MainMenu);
                                    }
                                    else if (result == 0)
                                    {
                                        Messenger.PlainMsg(client, "Your account has been created!", Enums.PlainMsgType.MainMenu);
                                    }
                                    else if (result == 1)
                                    {
                                        Messenger.PlainMsg(client, "That account already exists!", Enums.PlainMsgType.MainMenu);
                                    }
                                }
                            }
                        }
                        break;
                    case "addchar":
                        {
                            string name = parse[1].Trim();
                            int sex = parse[2].ToInt(-1);
                            //int CharClass = parse[3].ToInt(-1); ((This should be removed too))
                            //int CharNum = parse[4].ToInt(-1);
                            int charNum = parse[3].ToInt(-1);

                            for (int i = 0; i < name.Length; i++)
                            {
                                int n = (int)Convert.ToChar(name.Substring(i, 1));

                                if (n == 32 && (i == 0 || i == name.Length - 1))
                                {
                                    Messenger.PlainMsg(client, "Names cannot begin or end with spaces.", Enums.PlainMsgType.NewChar);
                                    return;
                                }

                                if ((n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n == 95) || (n == 32) || (n >= 48 && n <= 57))
                                {
                                }
                                else
                                {
                                    //Messenger.SendNewCharClasses(client); ((More classes?))
                                    Messenger.PlainMsg(client, "Invalid name, only letters, numbers, spaces, and _ allowed in names.", Enums.PlainMsgType.NewChar);
                                    return;
                                }
                            }

                            if (name.Length < 3 || name.Length > 24)
                            {
                                Messenger.PlainMsg(client, "Name must be between 3 and 24 letters long.", Enums.PlainMsgType.NewChar);
                                return;
                            }

                            if (charNum < 1 || charNum > 3)
                            {
                                Messenger.PlainMsg(client, "Invalid character number", Enums.PlainMsgType.Chars);
                                return;
                            }

                            if ((sex < (int)Enums.Sex.Genderless) || (sex > (int)Enums.Sex.Female))
                            {
                                Messenger.PlainMsg(client, "Invalid gender", Enums.PlainMsgType.Chars);
                                return;
                            }

                            //if (CharClass < 0 || CharClass > Settings.MaxClasses) {
                            //Messenger.PlainMsg(client, "Invalid class", Enums.PlainMsgType.Chars);
                            //return;
                            //} ((this should be removed. We no longer use classes in the Add Character Window))

                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                if (client.Player.CharacterExists(dbConnection, charNum))
                                {
                                    Messenger.PlainMsg(client, "That character is already in the Pokémon world!", Enums.PlainMsgType.NewChar);
                                    return;
                                }

                                if (PlayerManager.CharacterNameExists(dbConnection, name))
                                {
                                    Messenger.PlainMsg(client, "There's already a character with that name!", Enums.PlainMsgType.NewChar);
                                    return;
                                }

                                client.Player.CreateCharacter(dbConnection, name, (Enums.Sex)sex, charNum, false);
                            }
                        }
                        break;
                    case "delchar":
                        {
                            int charNum = parse[1].ToInt(-1);

                            if (charNum < 1 || charNum > 3)
                            {
                                Messenger.PlainMsg(client, "Invalid character number", Enums.PlainMsgType.Chars);
                                return;
                            }

                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                if (client.Player.CharacterExists(dbConnection, charNum))
                                {
                                    PlayerManager.DeleteCharacter(dbConnection, client.Player.AccountName, charNum);
                                    Messenger.SendChars(dbConnection, client);
                                    Messenger.PlainMsg(client, "The character has been sent back from the Pokémon world, never to return.", Enums.PlainMsgType.Chars);
                                }
                                else
                                {
                                    Messenger.PlainMsg(client, "That character doesn't exist!", Enums.PlainMsgType.Chars);
                                }
                            }
                        }
                        break;
                    case "deleteaccount":
                        {
                            string name = parse[1];
                            string password = parse[2];

                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                if (PlayerManager.AccountExists(dbConnection, name) == false)
                                {
                                    Messenger.PlainMsg(client, "That account does not exist", Enums.PlainMsgType.MainMenu);
                                    return;
                                }

                                if (PlayerManager.IsPasswordCorrect(dbConnection, name, password) == false)
                                {
                                    Messenger.PlainMsg(client, "Incorrect password", Enums.PlainMsgType.MainMenu);
                                    return;
                                }

                                PlayerManager.DeleteAccount(dbConnection, name);
                            }
                            Messenger.PlainMsg(client, "Your account has been deleted!", Enums.PlainMsgType.MainMenu);
                        }
                        break;
                    case "passchange":
                        {
                            string name = parse[1];
                            string oldPass = Security.Hash.GenerateMD5Hash(parse[2]);
                            string newPass = Security.Hash.GenerateMD5Hash(parse[3]);

                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                if (PlayerManager.IsPasswordCorrect(dbConnection, name, oldPass))
                                {
                                    PlayerManager.ChangeAccountPassword(dbConnection, name, oldPass, newPass);
                                    client.Player = new Player(client);
                                    Messenger.PlainMsg(client, "Your password has been changed!", Enums.PlainMsgType.AccountOptions);
                                }
                                else
                                {
                                    Messenger.PlainMsg(client, "Unable to change password.", Enums.PlainMsgType.AccountOptions);
                                }
                            }
                        }
                        break;
                    #endregion
                }
                #endregion
            }
            else
            {
                #region Logged In
                switch (parse[0].ToLower())
                {
                    #region Movement
                    case "playermove":
                        {
                            if (client.Player.GettingMap)
                            {
                                return;
                            }
                            int dir = parse[1].ToInt();
                            int speed = parse[2].ToInt();

                            if (dir < 0 || dir > 3)
                            {
                                return;
                            }
                            if (speed < 0 || speed > 7)
                            {
                                return;
                            }

                            MovementProcessor.ProcessMovement(client, (Enums.Direction)dir, (Enums.Speed)speed, false);
                        }
                        break;
                    case "critmove":
                        {
                            if (client.Player.GettingMap)
                            {
                                return;
                            }
                            int dir = parse[1].ToInt();
                            int speed = parse[2].ToInt();

                            if (dir < 0 || dir > 3)
                            {
                                return;
                            }
                            if (speed < 0 || speed > 7)
                            {
                                return;
                            }

                            MovementProcessor.ProcessMovement(client, (Enums.Direction)dir, (Enums.Speed)speed, true);
                        }
                        break;
                    case "playerdir":
                        {
                            if (client.Player.GettingMap)
                            {
                                return;
                            }
                            int dir = parse[1].ToInt();
                            if (dir < 0 || dir > 3)
                            {
                                return;
                            }

                            client.Player.Direction = (Enums.Direction)dir;
                            PacketHitList hitlist = null;
                            PacketHitList.MethodStart(ref hitlist);
                            PacketBuilder.AppendPlayerDirExcept(client, hitlist);
                            PacketHitList.MethodEnded(ref hitlist);
                        }
                        break;
                    case "requestnewmap":
                        {
                            //if (client.Player.Map.MapType != Enums.MapType.Instanced) {
                            int dir = parse[1].ToInt();

                            if (dir < 0 || dir > 3)
                            {
                                return;
                            }

                            if (MovementProcessor.WillWalkOnWarp(client, (Enums.Direction)dir))
                            {
                                MovementProcessor.ProcessMovement(client, (Enums.Direction)dir, (Enums.Speed)1, true);
                            }
                            else
                            {
                                PacketHitList hitlist = null;
                                PacketHitList.MethodStart(ref hitlist);
                                PacketBuilder.AppendOwnXY(client, hitlist);
                                PacketBuilder.AppendPlayerLock(client, hitlist, false);
                                PacketHitList.MethodEnded(ref hitlist);
                            }
                        }
                        break;
                    case "needmap":
                        {
                            Messenger.NeedMapCheck(client, parse[1].ToBool());
                        }
                        break;
                    case "needmapseamless":
                        {
                            bool[] results = new bool[parse[1].ToInt()];
                            int n = 2;
                            for (int i = 0; i < results.Length; i++)
                            {
                                results[i] = parse[n].ToBool();
                                n += 1;
                            }
                            Messenger.NeedMapCheck(client, results);
                        }
                        break;
                    case "refresh":
                        {
                            Messenger.RefreshMap(client);
                        }
                        break;
                    case "maploaded":
                        {
                            client.Player.Map.ProcessingPaused = true;
                        }
                        break;
                    #endregion
                    #region Attacking
                    case "attack":
                        {
                            if (client.Player.GettingMap) return;
                            client.Player.GetActiveRecruit().UseMove(-1);

                        }
                        break;
                    #endregion
                    #region Attacking - Moves
                    case "forgetspell":
                        {
                            // Spell slot
                            int n = parse[1].ToInt(-1);
                            // Prevent subscript out of range
                            if (n < 0 | n > Constants.MAX_PLAYER_MOVES)
                            {
                                Messenger.HackingAttempt(client, "Invalid Move Slot");
                                return;
                            }

                            if (client.Player.GetActiveRecruit().Moves[n].MoveNum == 0)
                            {
                                Messenger.PlayerMsg(client, "No move here.", Text.Red);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You have forgotten the move \"" + MoveManager.Moves[client.Player.GetActiveRecruit().Moves[n].MoveNum].Name.Trim() + "\"", Text.Green);
                                client.Player.GetActiveRecruit().Moves[n].MoveNum = 0;
                                client.Player.GetActiveRecruit().Moves[n].CurrentPP = -1;
                                client.Player.GetActiveRecruit().Moves[n].MaxPP = -1;
                                Messenger.SendPlayerMoves(client);
                            }

                        }
                        break;
                    case "swapmoves":
                        {
                            int oldMoveSlot = parse[1].ToInt(-1);
                            int newMoveSlot = parse[2].ToInt(-1);
                            if (oldMoveSlot > -1 && oldMoveSlot < 4 && newMoveSlot > -1 && newMoveSlot < 4)
                            {
                                RecruitMove oldMove = client.Player.GetActiveRecruit().Moves[oldMoveSlot];
                                RecruitMove newMove = client.Player.GetActiveRecruit().Moves[newMoveSlot];
                                client.Player.GetActiveRecruit().Moves[oldMoveSlot] = newMove;
                                client.Player.GetActiveRecruit().Moves[newMoveSlot] = oldMove;

                                Messenger.SendPlayerMoves(client);
                            }
                        }
                        break;
                    case "shiftspell":
                        {
                            // Spell slot
                            int n = parse[1].ToInt(-1);

                            // Prevent subscript out of range
                            if (n < 0 | n > Constants.MAX_PLAYER_MOVES)
                            {
                                Messenger.HackingAttempt(client, "Invalid Move Slot");
                                return;
                            }

                            //if (client.Player.GetActiveRecruit().Moves[n].MoveNum == 0) //~no need to check for blank space; you can move blank spaces
                            //{
                            //Messenger.PlayerMsg(client, "No move here.", Text.Red);
                            //}
                            //else
                            //{
                            int movingSpell = client.Player.GetActiveRecruit().Moves[n].MoveNum;
                            int movingSpellCurrentPP = client.Player.GetActiveRecruit().Moves[n].CurrentPP;
                            int movingSpellMaxPP = client.Player.GetActiveRecruit().Moves[n].MaxPP;

                            if (parse[2].ToBool() && n > 0)//shifting up
                            {
                                client.Player.GetActiveRecruit().Moves[n].MoveNum = client.Player.GetActiveRecruit().Moves[n - 1].MoveNum;
                                client.Player.GetActiveRecruit().Moves[n - 1].MoveNum = movingSpell;

                                client.Player.GetActiveRecruit().Moves[n].CurrentPP = client.Player.GetActiveRecruit().Moves[n - 1].CurrentPP;
                                client.Player.GetActiveRecruit().Moves[n - 1].CurrentPP = movingSpellCurrentPP;

                                client.Player.GetActiveRecruit().Moves[n].MaxPP = client.Player.GetActiveRecruit().Moves[n - 1].MaxPP;
                                client.Player.GetActiveRecruit().Moves[n - 1].MaxPP = movingSpellMaxPP;

                                Scripting.ScriptManager.InvokeSub("OnMoveSwapped", client, n, n - 1);
                            }
                            else if (n < 3)//shifting down
                            {
                                client.Player.GetActiveRecruit().Moves[n].MoveNum = client.Player.GetActiveRecruit().Moves[n + 1].MoveNum;
                                client.Player.GetActiveRecruit().Moves[n + 1].MoveNum = movingSpell;

                                client.Player.GetActiveRecruit().Moves[n].CurrentPP = client.Player.GetActiveRecruit().Moves[n + 1].CurrentPP;
                                client.Player.GetActiveRecruit().Moves[n + 1].CurrentPP = movingSpellCurrentPP;

                                client.Player.GetActiveRecruit().Moves[n].MaxPP = client.Player.GetActiveRecruit().Moves[n + 1].MaxPP;
                                client.Player.GetActiveRecruit().Moves[n + 1].MaxPP = movingSpellMaxPP;

                                Scripting.ScriptManager.InvokeSub("OnMoveSwapped", client, n, n + 1);
                            }

                            Messenger.SendPlayerMoves(client);
                            //}
                        }
                        break;
                    case "cast":
                        {
                            if (client.Player.GettingMap) return;
                            client.Player.GetActiveRecruit().UseMove(parse[1].ToInt(-1));
                        }
                        break;
                    #endregion
                    #region Messages
                    case "broadcastmsg":
                        if (CanSayMsg(client, parse[1]))
                        {
                            Scripting.ScriptManager.InvokeSub("OnChatMessageRecieved", client, parse[1], Enums.ChatMessageType.Global);

                            Logging.ChatLogger.AppendToChatLog("Global", client.Player.Name + ": " + parse[1]);

                            string playerName = client.Player.Name;
                            if (client.Player.Access != Enums.Rank.Normal)
                            {
                                playerName = "[c][" + Ranks.GetRankColor(client.Player.Access).ToArgb() + "]" + client.Player.Name + "[/c]";
                            }

                            Messenger.GlobalMsg("[Global] " + playerName + ": " + parse[1], Text.DarkGrey);
                        }
                        break;
                    case "saymsg":
                        if (CanSayMsg(client, parse[1]))
                        {
                            Scripting.ScriptManager.InvokeSub("OnChatMessageRecieved", client, parse[1], Enums.ChatMessageType.Map);

                            Logging.ChatLogger.AppendToChatLog("Maps/Map " + client.Player.MapID, client.Player.Name + ": " + parse[1]);

                            string playerName = client.Player.Name;
                            if (client.Player.Access != Enums.Rank.Normal)
                            {
                                playerName = "[c][" + Ranks.GetRankColor(client.Player.Access).ToArgb() + "]" + client.Player.Name + "[/c]";
                            }

                            PacketHitList hitList = null;
                            PacketHitList.MethodStart(ref hitList);
                            IMap playerMap = client.Player.GetCurrentMap();
                            hitList.AddPacketToMap(playerMap, PacketBuilder.CreateChatMsg(playerName + ": " + parse[1], Text.White));
                            hitList.AddPacketToMap(playerMap, PacketBuilder.CreateSpeechBubble(parse[1], client));
                            PacketHitList.MethodEnded(ref hitList);
                        }
                        break;
                    case "emotemsg":
                        if (CanSayMsg(client, parse[1]))
                        {
                            Scripting.ScriptManager.InvokeSub("OnChatMessageRecieved", client, parse[1], Enums.ChatMessageType.MeMsg);

                            Logging.ChatLogger.AppendToChatLog("Maps/Map " + client.Player.MapID, "(MeMsg) " + client.Player.Name + " " + parse[1]);

                            string playerName = client.Player.Name;
                            if (client.Player.Access != Enums.Rank.Normal)
                            {
                                playerName = "[c][" + Ranks.GetRankColor(client.Player.Access).ToArgb() + "]" + client.Player.Name + "[/c]";
                            }

                            Messenger.MapMsg(client.Player.MapID, playerName + " " + parse[1], Text.Blue);
                        }
                        break;
                    case "globalmsg":
                        if (CanSayMsg(client, parse[1]))
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                Scripting.ScriptManager.InvokeSub("OnChatMessageRecieved", client, parse[1], Enums.ChatMessageType.Announcement);

                                Logging.ChatLogger.AppendToChatLog("Global", "(Announcement) " + client.Player.Name + ": " + parse[1]);

                                string playerName = client.Player.Name;
                                if (client.Player.Access != Enums.Rank.Normal)
                                {
                                    playerName = "[c][" + Ranks.GetRankColor(client.Player.Access).ToArgb() + "]" + client.Player.Name + "[/c]";
                                }

                                Messenger.GlobalMsg("(Announcement) " + playerName + ": " + parse[1], Text.Green);
                            }
                        }
                        break;
                    case "adminmsg":
                        if (CanSayMsg(client, parse[1]))
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {

                                Scripting.ScriptManager.InvokeSub("OnChatMessageRecieved", client, parse[1], Enums.ChatMessageType.Staff);

                                Logging.ChatLogger.AppendToChatLog("Staff", client.Player.Name + ": " + parse[1]);

                                string playerName = client.Player.Name;
                                if (client.Player.Access != Enums.Rank.Normal)
                                {
                                    playerName = "[c][" + Ranks.GetRankColor(client.Player.Access).ToArgb() + "]" + client.Player.Name + "[/c]";
                                }

                                Messenger.AdminMsg("[Staff] " + playerName + ": " + parse[1], Text.Cyan);
                            }
                        }
                        break;
                    case "guildmsg":
                        if (CanSayMsg(client, parse[1]) && !string.IsNullOrEmpty(client.Player.GuildName))
                        {
                            Scripting.ScriptManager.InvokeSub("OnChatMessageRecieved", client, parse[1], Enums.ChatMessageType.Guild);

                            //Messenger.PlayerMsg(client, client.Player[client].mName + " (" + client.Player[client].mGuildName + ") " + parse[1], Text.Green);
                            Logging.ChatLogger.AppendToChatLog("Guild Chat/" + client.Player.GuildName, "(" + client.Player.GuildName + ") " + client.Player.Name + parse[1]);

                            string playerName = client.Player.Name;
                            if (client.Player.Access != Enums.Rank.Normal)
                            {
                                playerName = "[c][" + Ranks.GetRankColor(client.Player.Access).ToArgb() + "]" + client.Player.Name + "[/c]";
                            }

                            foreach (Client i in ClientManager.GetClients())
                            {
                                if (i.Player.GuildName == client.Player.GuildName)
                                {
                                    Messenger.PlayerMsg(i, "(" + client.Player.GuildName + ") " + playerName + parse[1], Text.Green);
                                }
                            }
                        }
                        break;
                    case "playermsg":
                        {
                            if (CanSayMsg(client, parse[2]))
                            {
                                Client msgto = ClientManager.FindClient(parse[1]);
                                if (msgto == null)
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                                else if (msgto == client)
                                {
                                    string sexString = "";
                                    if (client.Player.GetActiveRecruit().Sex == Enums.Sex.Genderless)
                                    {
                                        sexString = "it";
                                    }
                                    else if (client.Player.GetActiveRecruit().Sex == Enums.Sex.Male)
                                    {
                                        sexString = "him";
                                    }
                                    else if (client.Player.GetActiveRecruit().Sex == Enums.Sex.Female)
                                    {
                                        sexString = "her";
                                    }
                                    Messenger.MapMsg(client.Player.MapID, client.Player.Name + " begins to mumble to " + sexString + "self, what a wierdo...", Text.White);
                                }
                                else
                                {
                                    Scripting.ScriptManager.InvokeSub("OnChatMessageRecieved", client, parse[2], Enums.ChatMessageType.PM);

                                    Logging.ChatLogger.AppendToChatLog("PM/" + client.Player.Name, "(" + client.Player.Name + " tells " + msgto.Player.Name + ") " + parse[2]);

                                    string playerName = client.Player.Name;
                                    if (client.Player.Access != Enums.Rank.Normal)
                                    {
                                        playerName = "[c][" + Ranks.GetRankColor(client.Player.Access).ToArgb() + "]" + client.Player.Name + "[/c]";
                                    }

                                    string playerToName = msgto.Player.Name;
                                    if (msgto.Player.Access != Enums.Rank.Normal)
                                    {
                                        playerToName = "[c][" + Ranks.GetRankColor(msgto.Player.Access).ToArgb() + "]" + msgto.Player.Name + "[/c]";
                                    }

                                    Messenger.PlayerMsg(client, "You tell " + playerToName + ", '" + parse[2] + "'", Text.Pink);
                                    Messenger.PlayerMsg(msgto, playerName + " tells you, '" + parse[2] + "'", Text.Pink);
                                }

                            }
                        }
                        break;
                    #endregion
                    #region Recruits
                    case "requestactivecharswap":
                        {//perhaps put a time requirement for switching...
                            if (client.Player.GettingMap) return;
                            //if (client.Player.PK == false) {
                            client.Player.SwapActiveRecruit(parse[1].ToInt(1));
                            //} else {
                            //    Messenger.PlayerMsg(client, "An outlaw can't switch Pokémon!", Text.BrightRed);
                            //}
                        }
                        break;
                    case "switchleader":
                        {
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Assembly)
                            {
                                //if (client.Player.PK == false) {
                                client.Player.SwapLeader(parse[1].ToInt(1));

                                //} else {
                                //    Messenger.PlayerMsg(client, "An outlaw can't switch leaders!", Text.BrightRed);
                                //}
                            }
                            else
                            {
                                Messenger.HackingAttempt(client, "Player not in Assembly");
                            }
                        }
                        break;
                    case "addtoteam":
                        if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Assembly)
                        {
                            int teamSlot = parse[1].ToInt(-1);
                            client.Player.AddToTeam(parse[2].ToInt(-1), teamSlot);
                            if (client.Player.Team[teamSlot] != null && client.Player.Team[teamSlot].Loaded)
                            {
                                client.Player.Team[teamSlot].HP = client.Player.Team[teamSlot].MaxHP;
                            }
                            Messenger.SendActiveTeam(client);
                            Messenger.SendStats(client);
                            Messenger.SendAllRecruits(client);
                        }
                        else
                        {
                            Messenger.SendPlayerData(client);
                            Messenger.HackingAttempt(client, "Player not in Assembly");
                        }
                        break;
                    case "removefromteam":
                        client.Player.RemoveFromTeam(parse[1].ToInt(-1));

                        break;
                    case "standby":
                        client.Player.RemoveFromTeam(parse[1].ToInt(-1));
                        Messenger.SendAllRecruits(client);
                        break;
                    case "releaserecruit":
                        client.Player.RequestedRecruit = new Recruit(client);
                        client.Player.RequestedRecruit.RecruitIndex = parse[1].ToInt(-1);
                        Messenger.AskQuestion(client, "ReleasePokemon", "Are you sure you want to release this recruit?", -1);
                        break;
                    case "changerecruitname":
                        if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Assembly)
                        {
                            if (client.Player.Muted == false)
                            {
                                if (parse[2].Length >= 3 && parse[2].Length <= 24)
                                {
                                    client.Player.ChangeRecruitName(parse[1].ToInt(-1), parse[2]);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Name must be between 3 and 24 letters long.", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You cannot change nicknames while muted!", Text.BrightRed);
                            }
                        }
                        else
                        {
                            Messenger.SendPlayerData(client);
                            Messenger.HackingAttempt(client, "Player not in Assembly");
                        }
                        break;
                    #endregion
                    #region Missions
                    case "acceptmission":
                        {
                            if (client.Player.Map.Moral == Enums.MapMoral.House || client.Player.Map.Moral == Enums.MapMoral.Safe)
                            {
                                int slot = parse[1].ToInt(-1);
                                if (slot > -1 && slot < client.Player.MissionBoard.BoardMissions.Count)
                                {
                                    bool taken = client.Player.JobList.AddJob(new WonderMails.WonderMailJob(client.Player.MissionBoard.BoardMissions[slot]));
                                    if (taken)
                                    {
                                        client.Player.MissionBoard.BoardMissions.RemoveAt(slot);
                                        Messenger.SendRemovedMission(client, slot);
                                        Messenger.SendNewJob(client);
                                    }
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't accept a job here!", Text.BrightRed);
                            }
                        }
                        break;
                    case "startmission":
                        {
                            if (client.Player.Map.Moral == Enums.MapMoral.House || client.Player.Map.Moral == Enums.MapMoral.Safe)
                            {
                                int slot = parse[1].ToInt(-1);
                                if (slot > -1 && slot < client.Player.JobList.JobList.Count)
                                {
                                    client.Player.JobList.JobList[slot].Accepted = Enums.JobStatus.Taken;
                                    Messenger.SendJobAccept(client, slot);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't take a job here!", Text.BrightRed);
                            }
                        }
                        break;
                    case "deletejob":
                        {
                            if (client.Player.Map.Moral == Enums.MapMoral.House || client.Player.Map.Moral == Enums.MapMoral.Safe)
                            {
                                int slot = parse[1].ToInt(-1);
                                if (slot > -1 && slot < client.Player.JobList.JobList.Count)
                                {
                                    client.Player.JobList.RemoveJob(slot);
                                    Messenger.SendDeleteJob(client, slot);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't delete a job here!", Text.BrightRed);
                            }
                        }
                        break;
                    case "sendmission":
                        {
                            if (client.Player.Map.Moral == Enums.MapMoral.House || client.Player.Map.Moral == Enums.MapMoral.Safe)
                            {
                                Client target = ClientManager.FindClient(parse[2]);
                                if (target != null)
                                {
                                    if (target != client)
                                    {
                                        int slot = parse[1].ToInt(-1);
                                        if (target.Player.GetDungeonCompletionCount(client.Player.JobList.JobList[slot].Mission.DungeonIndex) > 0)
                                        {
                                            if (target.Player.JobList.JobList.Count < Constants.MAX_JOB_LIST)
                                            {
                                                if (Combat.MoveProcessor.IsInAreaRange(1, client.Player.X, client.Player.Y, target.Player.X, target.Player.Y))
                                                {

                                                    if (slot > -1 && slot < client.Player.JobList.JobList.Count)
                                                    {
                                                        client.Player.JobList.JobList[slot].SendsRemaining--;
                                                        if (client.Player.JobList.JobList[slot].SendsRemaining <= 0)
                                                        {
                                                            //send sends remaining
                                                            Messenger.SendRemainingJobSends(client, slot);
                                                        }
                                                        target.Player.JobList.AddJobSimple(new WonderMails.WonderMailJob(client.Player.JobList.JobList[slot]));
                                                        Messenger.PlayerMsg(client, "A Wonder Mail was sent to " + target.Player.Name + "!", Text.BrightGreen);
                                                        Messenger.PlayerMsg(target, client.Player.Name + " has sent you a Wonder Mail!", Text.BrightGreen);
                                                        Messenger.SendNewJob(target);
                                                    }

                                                }
                                                else
                                                {
                                                    Messenger.PlayerMsg(client, "You have to stand next to the player to send a Wonder Mail.", Text.BrightRed);
                                                }
                                            }
                                            else
                                            {
                                                Messenger.PlayerMsg(client, "That player's job list is full.", Text.BrightRed);
                                            }
                                        }
                                        else
                                        {
                                            Messenger.PlayerMsg(client, "That player has not yet completed the dungeon specified in the Wonder Mail.", Text.BrightRed);
                                        }
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "You can't send a Wonder Mail to yourself!", Text.BrightRed);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "There's no one online with that name.", Text.BrightRed);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't send a Wonder Mail here!", Text.BrightRed);
                            }
                        }
                        break;
                    case "canceljob":
                        {
                            if (client.Player.Map.Moral == Enums.MapMoral.House || client.Player.Map.Moral == Enums.MapMoral.Safe)
                            {
                                int slot = parse[1].ToInt(-1);
                                if (slot > -1 && slot < client.Player.JobList.JobList.Count)
                                {
                                    client.Player.JobList.JobList[slot].Accepted = Enums.JobStatus.Suspended;
                                    Messenger.SendJobAccept(client, slot);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "You can't cancel a job here!", Text.BrightRed);
                            }
                        }
                        break;
                    //case "requestmissioncode": {
                    //        int slot = parse[1].ToInt(-1);
                    //        if (slot > -1 && slot < client.Player.JobList.JobList.Count) {
                    //            if (client.Player.JobList.JobList[slot] != null) {
                    //                WonderMails.IssuedWonderMailEntry entry = WonderMails.WonderMailSystem.FindIssuedWonderMailByCode(client.Player.JobList.JobList[slot].Mission.EncryptedCode);
                    //                if (entry == null) {
                    //                    // This code has not yet been issued
                    //                } else {

                    //                }

                    //                Messenger.SendMissionCode(client, client.Player.JobList.JobList[slot].Mission);
                    //            }
                    //        }
                    //    }
                    //    break;
                    #endregion
                    #region Misc
                    case "ping":
                        //Messenger.SendDataTo(client, TcpPacket.CreatePacket("ping"));
                        break;
                    case "search":
                        {
                            int X = parse[1].ToInt(-1);
                            int Y = parse[2].ToInt(-1);

                            IMap map = client.Player.GetCurrentMap();

                            // Prevent subscript out of range
                            if (X < 0 || X > map.MaxX || Y < 0 || Y > map.MaxY)
                            {
                                return;
                            }

                            // Check for a player
                            foreach (Client i in map.GetClients())
                            {
                                if (i.IsPlaying() && map == i.Player.Map && i.Player.X == X && i.Player.Y == Y)
                                {
                                    // Consider the player
                                    if (MovementProcessor.CanCharacterSeeCharacter(map, client.Player.GetActiveRecruit(), i.Player.GetActiveRecruit()))
                                    {
                                        if (MovementProcessor.CanCharacterIdentifyCharacter(map, client.Player.GetActiveRecruit(), i.Player.GetActiveRecruit()))
                                        {
                                            if (i == client)
                                            {
                                                Messenger.PlayerMsg(client, "You look upon yourself.", Text.Yellow);
                                            }
                                            else
                                            {
                                                Messenger.PlayerMsg(client, "You see " + i.Player.Name + ".", Text.Yellow);
                                                if (i.Player.GetActiveRecruit().Level >= client.Player.GetActiveRecruit().Level + 5)
                                                {
                                                    Messenger.PlayerMsg(client, "This Pokémon appears to be much more experienced than you.", Text.BrightRed);
                                                }
                                                else if (i.Player.GetActiveRecruit().Level > client.Player.GetActiveRecruit().Level)
                                                {
                                                    Messenger.PlayerMsg(client, "This Pokémon appears to be slightly more experienced than you.", Text.Yellow);
                                                }
                                                else if (i.Player.GetActiveRecruit().Level == client.Player.GetActiveRecruit().Level)
                                                {
                                                    Messenger.PlayerMsg(client, "This Pokémon seems to be about as experienced as you.", Text.White);
                                                }
                                                else if (client.Player.GetActiveRecruit().Level >= i.Player.GetActiveRecruit().Level + 5)
                                                {
                                                    Messenger.PlayerMsg(client, "This Pokémon appears much less experienced than you.", Text.BrightBlue);
                                                }
                                                else if (client.Player.GetActiveRecruit().Level > i.Player.GetActiveRecruit().Level)
                                                {
                                                    Messenger.PlayerMsg(client, "This Pokémon appears slightly less experienced than you.", Text.Yellow);
                                                }
                                            }
                                            return;
                                        }
                                        else
                                        {
                                            Messenger.PlayerMsg(client, "You see a Pokémon.", Text.Yellow);
                                            return;
                                        }
                                    }
                                }
                            }

                            // Check for an npc
                            for (int i = 0; i < Constants.MAX_MAP_NPCS; i++)
                            {
                                if (map.ActiveNpc[i].Num > 0)
                                {
                                    if (map.ActiveNpc[i].X == X && map.ActiveNpc[i].Y == Y)
                                    {
                                        if (MovementProcessor.CanCharacterSeeCharacter(map, client.Player.GetActiveRecruit(), map.ActiveNpc[i]))
                                        {
                                            if (MovementProcessor.CanCharacterIdentifyCharacter(map, client.Player.GetActiveRecruit(), map.ActiveNpc[i]))
                                            {
                                                Messenger.PlayerMsg(client, "You see a " + NpcManager.Npcs[map.ActiveNpc[i].Num].Name.Trim() + ".", Text.Yellow);

                                                if (!map.RecruitEnabled)
                                                {
                                                    Messenger.PlayerMsg(client, NpcManager.Npcs[map.ActiveNpc[i].Num].Name.Trim() + " cannot be recruited in this area.", Text.Yellow);

                                                }
                                                else if (map.ActiveNpc[i].Level >= client.Player.GetActiveRecruit().Level)
                                                {
                                                    Messenger.PlayerMsg(client, NpcManager.Npcs[map.ActiveNpc[i].Num].Name.Trim() + "'s level is too high for you to recruit it.", Text.Yellow);

                                                }
                                                else if (NpcManager.Npcs[map.ActiveNpc[i].Num].RecruitRate != 0)
                                                {
                                                    int recruitRate = NpcManager.Npcs[map.ActiveNpc[i].Num].RecruitRate;
                                                    //Messenger.PlayerMsg(client, NpcManager.Npcs[map.ActiveNpc[i].Num].Name.Trim() + "'s recruit rate is " + NpcManager.Npcs[map.ActiveNpc[i].Num].RecruitRate + " (+" + client.Player.GetRecruitBonus() + ")", Text.Yellow);
                                                    Messenger.PlayerMsg(client, "You have a " + (recruitRate / 10f) + "% of recruiting " + NpcManager.Npcs[map.ActiveNpc[i].Num].Name.Trim() + "!", Text.Yellow);
                                                }
                                                else
                                                {
                                                    Messenger.PlayerMsg(client, NpcManager.Npcs[map.ActiveNpc[i].Num].Name.Trim() + " is not recruitable.", Text.Yellow);
                                                }
                                                return;
                                            }
                                            else
                                            {
                                                Messenger.PlayerMsg(client, "You see a Pokémon.", Text.Yellow);
                                                return;
                                            }
                                        }
                                    }
                                }
                            }

                            for (int i = 0; i < Constants.MAX_MAP_ITEMS; i++)
                            {
                                if (map.ActiveItem[i].Num > 0/* && !map.ActiveItem[i].Hidden*/)
                                {
                                    if (map.ActiveItem[i].X == X && map.ActiveItem[i].Y == Y)
                                    {
                                        if (MovementProcessor.CanCharacterSeeDestination(map, client.Player.GetActiveRecruit(), X, Y) && !map.ActiveItem[i].Hidden)
                                        {
                                            if (MovementProcessor.CanCharacterIdentifyDestination(map, client.Player.GetActiveRecruit(), X, Y) && !map.ActiveItem[i].Hidden)
                                            {
                                                if (map.ActiveItem[i].Sticky)
                                                {
                                                    Messenger.PlayerMsg(client, "You see a x" + ItemManager.Items[map.ActiveItem[i].Num].Name.Trim() + ".", Text.Yellow);
                                                    return;
                                                }
                                                else
                                                {
                                                    Messenger.PlayerMsg(client, "You see a " + ItemManager.Items[map.ActiveItem[i].Num].Name.Trim() + ".", Text.Yellow);
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                Messenger.PlayerMsg(client, "You notice an item.", Text.Yellow);
                                                return;
                                            }
                                        }
                                    }
                                }
                            }

                            Scripting.ScriptManager.InvokeSub("OnClick", client, map, X, Y);
                        }
                        break;
                    case "mapgetitem":
                        {
                            // Check for scripted signs
                            if (client.Player.GettingMap) return;
                            IMap map = client.Player.GetCurrentMap();
                            int newX = client.Player.X;
                            int newY = client.Player.Y;
                            Enums.Direction dir = client.Player.Direction;
                            switch (client.Player.Direction)
                            {
                                case Enums.Direction.Up:
                                    newY--;
                                    break;
                                case Enums.Direction.Down:
                                    newY++;
                                    break;
                                case Enums.Direction.Left:
                                    newX--;
                                    break;
                                case Enums.Direction.Right:
                                    newX++;
                                    break;
                            }
                            if (newX >= 0 && newX < map.MaxX && newY >= 0 && newY < map.MaxY)
                            {
                                if (map.Tile[newX, newY].Type == Enums.TileType.ScriptedSign)
                                {
                                    Scripting.ScriptManager.InvokeSub("ScriptedSign", client, map.Tile[newX, newY].Data1, map.Tile[newX, newY].String1, map.Tile[newX, newY].String2, map.Tile[newX, newY].String3, dir);
                                }
                                else if (map.Tile[newX, newY].Type == Enums.TileType.Key)
                                {
                                    bool moveUsed = false;
                                    for (int i = 0; i < client.Player.GetActiveRecruit().Moves.Length; i++)
                                    {
                                        if (client.Player.GetActiveRecruit().Moves[i].MoveNum > -1)
                                        {
                                            Move move = MoveManager.Moves[client.Player.GetActiveRecruit().Moves[i].MoveNum];
                                            if (move.KeyItem > 0)
                                            {
                                                if (move.KeyItem == map.Tile[newX, newY].Data1)
                                                {
                                                    Messenger.AskQuestion(client, "UseMoveKeyOnEnter", "Would you like to use " + move.Name + "?", -1, new string[] { "Yes", "No" });
                                                    moveUsed = true;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    if (moveUsed == false)
                                    {
                                        for (int i = 1; i <= client.Player.MaxInv; i++)
                                        {
                                            if (client.Player.Inventory[i].Num == map.Tile[newX, newY].Data1)
                                            {
                                                if (ItemManager.Items[client.Player.Inventory[i].Num].Type == Enums.ItemType.Key)
                                                {
                                                    Messenger.AskQuestion(client, "UseKeyOnEnter", "Would you like to use your " + ItemManager.Items[client.Player.Inventory[i].Num].Name + " to unlock the door?", -1, new string[] { "Yes", "No" });
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            client.Player.PickupItem();
                        }
                        break;
                    case "mapdropitem":
                        {
                            if (client.Player.GettingMap) return;
                            int invNum = parse[1].ToInt();
                            int amount = parse[2].ToInt();

                            // Prevent hacking
                            if (invNum < 1 || invNum > client.Player.MaxInv || client.Player.Inventory[invNum].Num <= 0)
                            {
                                Messenger.HackingAttempt(client, "Invalid InvNum: " + invNum);
                                return;
                            }

                            // Prevent hacking
                            if (ItemManager.Items[client.Player.Inventory[invNum].Num].Type == Enums.ItemType.Currency || ItemManager.Items[client.Player.Inventory[invNum].Num].StackCap > 0)
                            {
                                // Check if money and if it is we want to make sure that they aren't trying to drop 0 value
                                if (amount <= 0)
                                {
                                    Messenger.PlayerMsg(client, "You must drop more than 0!", Text.BrightRed);
                                    return;
                                }

                                if (amount > client.Player.Inventory[invNum].Amount)
                                {
                                    Messenger.PlayerMsg(client, "You dont have that much to drop!", Text.BrightRed);
                                    return;
                                }
                            }

                            // Prevent hacking
                            if (ItemManager.Items[client.Player.Inventory[invNum].Num].Type != Enums.ItemType.Currency && ItemManager.Items[client.Player.Inventory[invNum].Num].StackCap > 0)
                            {
                                if (amount > client.Player.Inventory[invNum].Amount)
                                {
                                    Messenger.HackingAttempt(client, "Item amount modification");
                                    return;
                                }
                            }

                            client.Player.DropItem(invNum, amount);
                            //Messenger.SendStats(client);
                        }
                        break;
                    case "adventurelog":
                        {
                            Messenger.SendAdventureLog(client);
                        }
                        break;
                    case "checkarrows":
                        {
                            //int n = ArrowManagerBase.Arrows[parse[1].ToInt()].Pic;
                            //Messenger.SendDataToMap(client.Player.MapID, TcpPacket.CreatePacket("checkarrows", client.ToString(), n.ToString()));
                        }
                        break;
                    case "checkemoticons":
                        {
                            if (client.Player.Muted == false)
                            {
                                int n = EmoticonManagerBase.Emoticons[parse[1].ToInt()].Pic;
                                Messenger.SendDataToMap(client.Player.MapID, TcpPacket.CreatePacket("checkemoticons", client.ToString(), n.ToString()));
                            }
                        }
                        break;
                    case "clienterror":
                        {
                            string error = parse[1];
                            error += "\r\n\r\n------- ERROR REPORT END -------\r\n\r\n";
                            Logging.Logger.AppendToLog("/Client Error Logs/" + DateTime.Now.ToShortDateString().Replace("/", "-") + "/log.txt", error);
                        }
                        break;
                    #endregion
                    #region Scripts
                    case "hotscript1":
                        Scripting.ScriptManager.InvokeSub("HotScript1", client);
                        break;
                    case "hotscript2":
                        Scripting.ScriptManager.InvokeSub("HotScript2", client);
                        break;
                    case "hotscript3":
                        Scripting.ScriptManager.InvokeSub("HotScript3", client);
                        break;
                    case "hotscript4":
                        Scripting.ScriptManager.InvokeSub("HotScript4", client);
                        break;
                    case "questionresult":
                        if (!string.IsNullOrEmpty(client.Player.QuestionID))
                        {
                            string id = client.Player.QuestionID;
                            client.Player.QuestionID = "";

                            if (id.StartsWith("DropItem:"))
                            {
                                if (parse[1] == "Yes")
                                {
                                    string[] parseID = id.Split(':');
                                    int itemSlot = parseID[1].ToInt();
                                    int amount = parseID[2].ToInt();
                                    if (client.Player.Inventory[itemSlot].Num <= 0) return;
                                    if (client.Player.Inventory[itemSlot].Amount < amount) return;
                                    if (amount == 0) amount = 1;
                                    int payout = ItemManager.Items[client.Player.Inventory[itemSlot].Num].Price * amount;
                                    if (client.Player.FindInvSlot(1, payout) == -1)
                                    {
                                        Messenger.PlayerMsg(client, "You can't carry any more " + ItemManager.Items[1].Name + ".", Text.BrightRed);
                                        return;
                                    }
                                    client.Player.GiveItem(1, payout);
                                    Messenger.PlayerMsg(client, "Trade successful!", Text.Yellow);
                                    client.Player.TakeItemSlot(itemSlot, amount, true);
                                    //client.Player.DropItem(itemSlot, amount, null, true);
                                }
                            }

                            switch (id)
                            {
                                case "BuyItem":
                                    {
                                        if (parse[1] == "Yes")
                                        {
                                            if (client.Player.HasItem(1) < client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1)
                                            {
                                                Messenger.PlayerMsg(client, "You don't have enough " + ItemManager.Items[1].Name + " to buy this item!", Text.BrightRed);
                                                return;
                                            }

                                            if (String.IsNullOrEmpty(client.Player.Map.Tile[client.Player.X, client.Player.Y].String1))
                                            {
                                                Messenger.PlayerMsg(client, "Trade successful!", Text.Yellow);
                                                client.Player.PickupItem(true);
                                                client.Player.TakeItem(1, client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1, true);
                                            }
                                            else
                                            {
                                                int slot = client.Player.FindInvSlot(1);
                                                if (slot == -1 || client.Player.Inventory[slot].Num != 1) return;
                                                Messenger.PlayerMsg(client, "Trade successful!", Text.Yellow);
                                                client.Player.PickupItem(true);
                                                client.Player.DropItem(slot, client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1, null, true);
                                            }
                                        }
                                    }
                                    break;
                                case "CreateGuild":
                                    {
                                        #region CreateGuild Result
                                        if (parse[1] == "Cancel")
                                        {
                                            client.Player.GuildName = "";
                                        }
                                        #endregion
                                    }
                                    break;
                                case "GuildStepDown":
                                    {
                                        #region GuildStepDown Result
                                        if (parse[1] == "Yes")
                                        {
                                            Guilds.GuildManager.GuildStepDown(client);
                                        }
                                        #endregion
                                    }
                                    break;
                                case "DisbandGuild":
                                    {
                                        #region DisbandGuild Result
                                        if (parse[1] == "Yes")
                                        {
                                            Guilds.GuildManager.DisbandGuild(client);
                                        }
                                        #endregion
                                    }
                                    break;
                                case "RecruitPokemon":
                                    {
                                        #region RecruitPokemon Result
                                        if (parse[1] == "Yes")
                                        {
                                            int openSlot = client.Player.FindOpenTeamSlot();
                                            int recruitIndex = 0;
                                            if (openSlot != -1)
                                            {
                                                if (client.Player.RequestedRecruit.Level > 0)
                                                {
                                                    using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                                    {
                                                        recruitIndex = client.Player.AddToRecruitmentBank(dbConnection, client.Player.RequestedRecruit);
                                                    }

                                                    if (recruitIndex != -1)
                                                    {
                                                        client.Player.AddToTeam(recruitIndex, openSlot);
                                                        client.Player.Team[openSlot].HP = client.Player.Team[openSlot].MaxHP;
                                                        Messenger.BattleMsg(client, "You have recruited a new team member!", Text.BrightGreen);

                                                        Messenger.SendActiveTeam(client);
                                                    }
                                                    else
                                                    {
                                                        Messenger.BattleMsg(client, "You cant recruit! You have too many team members in the assembly!", Text.BrightRed);
                                                    }
                                                }
                                                else
                                                {
                                                    Messenger.BattleMsg(client, "You cant recruit! Error 2", Text.BrightRed);
                                                }
                                            }
                                            else
                                            {
                                                Messenger.BattleMsg(client, "You cant recruit! Your team is full!", Text.BrightRed);
                                            }
                                        }
                                        else
                                        {
                                            client.Player.RequestedRecruit = null;
                                        }

                                        client.Player.RequestedRecruit = null;
                                        #endregion
                                    }
                                    break;
                                case "ReleasePokemon":
                                    {
                                        #region ReleasePokemon Result
                                        if (parse[1] == "Yes")
                                        {

                                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                            {
                                                client.Player.ReleaseRecruit(dbConnection, client.Player.RequestedRecruit.RecruitIndex);
                                            }

                                        }
                                        client.Player.RequestedRecruit = null;
                                        #endregion
                                    }
                                    break;
                                case "MovesFull":
                                    {
                                        #region MovesFull Result
                                        if (parse[1] == "Yes")
                                        {
                                            bool allowLearn = true;
                                            if (client.Player.GetActiveRecruit().MoveItem != -1)
                                            {
                                                if (client.Player.HasItem(client.Player.GetActiveRecruit().MoveItem, true) > 0)
                                                {
                                                    client.Player.TakeItem(client.Player.GetActiveRecruit().MoveItem, 0, true);
                                                }
                                                else
                                                {
                                                    allowLearn = false;
                                                }
                                            }
                                            if (allowLearn)
                                            {
                                                Messenger.OpenMoveForgetMenu(client);
                                            }
                                            client.Player.GetActiveRecruit().MoveItem = -1;
                                        }
                                        else
                                        {
                                            client.Player.GetActiveRecruit().MoveItem = -1;
                                            Messenger.PlayerMsg(client, "You chose to not learn this move.", Text.White);
                                        }
                                        #endregion
                                    }
                                    break;
                                case "PlayerTradeRequest":
                                    {
                                        #region PlayerTradeRequest Result
                                        if (parse[1] == "Yes")
                                        {
                                            Client tradePartner = ClientManager.FindClientFromCharID(client.Player.TradePartner);
                                            if (tradePartner != null)
                                            {
                                                tradePartner.Player.TradePartner = client.Player.CharID;
                                                Messenger.OpenTradeMenu(client);
                                            }
                                        }
                                        #endregion
                                    }
                                    break;
                                case "SingleEvolution":
                                    {
                                        #region SingleEvolution Result

                                        PacketHitList hitlist = null;
                                        PacketHitList.MethodStart(ref hitlist);

                                        if (parse[1] == "Yes")
                                        {
                                            int speciesNum = client.Player.GetActiveRecruit().Species;
                                            int evoIndex = -1;
                                            for (int z = 0; z < EvolutionManager.Evolutions.MaxEvos; z++)
                                            {
                                                if (EvolutionManager.Evolutions[z].Species == speciesNum)
                                                {
                                                    evoIndex = z;
                                                }
                                            }
                                            if (evoIndex == -1) return;

                                            List<int> viableEvos = EvolutionManager.FindViableEvolutions(client, evoIndex);
                                            if (viableEvos.Count == 1)
                                            {
                                                EvolutionBranch evo = Evolutions.EvolutionManager.Evolutions[evoIndex].Branches[viableEvos[0]];
                                                client.Player.GetActiveRecruit().SetSpecies(evo.NewSpecies);
                                                if (client.Player.GetActiveRecruit().RecruitIndex > -2)
                                                {
                                                    client.Player.PokemonCaught(client.Player.GetActiveRecruit().Species);
                                                }
                                                PacketBuilder.AppendPlayerData(client, hitlist);
                                                Messenger.SendActiveTeam(client);
                                                PacketBuilder.AppendStats(client, hitlist);
                                                hitlist.AddPacket(client, PacketBuilder.CreateChatMsg("You have evolved into " + Pokedex.Pokedex.GetPokemon(client.Player.GetActiveRecruit().Species).Name + "! Congratulations!", Text.Yellow));
                                                Scripting.ScriptManager.InvokeFunction("OnEvoDone", client, evo.ReqScript, evo.Data1, evo.Data2, evo.Data3);
                                            }

                                        }

                                        PacketHitList.MethodEnded(ref hitlist);

                                        #endregion
                                    }
                                    break;
                                case "BranchEvolution":
                                    {
                                        #region BranchEvolution Result
                                        PacketHitList hitlist = null;
                                        PacketHitList.MethodStart(ref hitlist);
                                        if (parse[1] == "Cancel") return;
                                        int speciesNum = client.Player.GetActiveRecruit().Species;
                                        int evoIndex = -1;
                                        for (int z = 0; z < EvolutionManager.Evolutions.MaxEvos; z++)
                                        {
                                            if (EvolutionManager.Evolutions[z].Species == speciesNum)
                                            {
                                                evoIndex = z;
                                            }
                                        }
                                        if (evoIndex == -1) return;

                                        for (int i = 0; i <= EvolutionManager.Evolutions[evoIndex].Branches.Count; i++)
                                        {
                                            bool canEvolve = Scripting.ScriptManager.InvokeFunction("ScriptedEvoReq", client, EvolutionManager.Evolutions[evoIndex].Branches[i].ReqScript, EvolutionManager.Evolutions[evoIndex].Branches[i].Data1, EvolutionManager.Evolutions[evoIndex].Branches[i].Data2, EvolutionManager.Evolutions[evoIndex].Branches[i].Data3).ToBool();
                                            if (canEvolve && EvolutionManager.Evolutions[evoIndex].Branches[i].Name == parse[1])
                                            {
                                                EvolutionBranch evo = Evolutions.EvolutionManager.Evolutions[evoIndex].Branches[i];
                                                client.Player.GetActiveRecruit().SetSpecies(evo.NewSpecies);
                                                if (client.Player.GetActiveRecruit().RecruitIndex > -2)
                                                {
                                                    client.Player.PokemonCaught(client.Player.GetActiveRecruit().Species);
                                                }
                                                PacketBuilder.AppendPlayerData(client, hitlist);
                                                Messenger.SendActiveTeam(client);
                                                PacketBuilder.AppendStats(client, hitlist);
                                                hitlist.AddPacket(client, PacketBuilder.CreateChatMsg("You have evolved into " + Pokedex.Pokedex.GetPokemon(client.Player.GetActiveRecruit().Species).Name + "! Congratulations!", Text.Yellow));
                                                Scripting.ScriptManager.InvokeFunction("OnEvoDone", client, evo.ReqScript, evo.Data1, evo.Data2, evo.Data3);
                                                break;
                                            }
                                        }

                                        PacketHitList.MethodEnded(ref hitlist);

                                        //Scripting.ScriptManager.InvokeFunction("EvoDone", player.Client, Evolutions[evoIndex].Branches[i].ReqScript, Evolutions[evoIndex].Branches[i].Data1, Evolutions[evoIndex].Branches[i].Data2, Evolutions[evoIndex].Branches[i].Data3)
                                        #endregion
                                    }
                                    break;
                                case "UseKeyOnEnter":
                                    {
                                        #region UseKeyOnEnter Result
                                        if (parse[1] == "Yes")
                                        {
                                            IMap map = client.Player.GetCurrentMap();
                                            int newX = client.Player.X;
                                            int newY = client.Player.Y;
                                            Enums.Direction dir = client.Player.Direction;
                                            switch (client.Player.Direction)
                                            {
                                                case Enums.Direction.Up:
                                                    newY--;
                                                    break;
                                                case Enums.Direction.Down:
                                                    newY++;
                                                    break;
                                                case Enums.Direction.Left:
                                                    newX--;
                                                    break;
                                                case Enums.Direction.Right:
                                                    newX++;
                                                    break;
                                            }
                                            if (newX >= 0 && newX < map.MaxX && newY >= 0 && newY < map.MaxY)
                                            {
                                                if (map.Tile[newX, newY].Type == Enums.TileType.Key)
                                                {
                                                    for (int i = 1; i <= client.Player.MaxInv; i++)
                                                    {
                                                        if (client.Player.Inventory[i].Num == map.Tile[newX, newY].Data1)
                                                        {
                                                            client.Player.UseItem(client.Player.Inventory[i], i);
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else if (parse[1] == "No")
                                        {

                                        }
                                        #endregion
                                    }
                                    break;
                                case "UseMoveKeyOnEnter":
                                    {
                                        #region UseKeyOnEnter Result
                                        if (parse[1] == "Yes")
                                        {
                                            IMap map = client.Player.GetCurrentMap();
                                            int newX = client.Player.X;
                                            int newY = client.Player.Y;
                                            Enums.Direction dir = client.Player.Direction;
                                            switch (client.Player.Direction)
                                            {
                                                case Enums.Direction.Up:
                                                    newY--;
                                                    break;
                                                case Enums.Direction.Down:
                                                    newY++;
                                                    break;
                                                case Enums.Direction.Left:
                                                    newX--;
                                                    break;
                                                case Enums.Direction.Right:
                                                    newX++;
                                                    break;
                                            }
                                            if (newX >= 0 && newX < map.MaxX && newY >= 0 && newY < map.MaxY)
                                            {
                                                if (map.Tile[newX, newY].Type == Enums.TileType.Key)
                                                {
                                                    for (int i = 0; i < client.Player.GetActiveRecruit().Moves.Length; i++)
                                                    {
                                                        if (client.Player.GetActiveRecruit().Moves[i].MoveNum > -1)
                                                        {
                                                            Move move = MoveManager.Moves[client.Player.GetActiveRecruit().Moves[i].MoveNum];
                                                            if (move.KeyItem > 0)
                                                            {
                                                                if (move.KeyItem == map.Tile[newX, newY].Data1)
                                                                {
                                                                    client.Player.GetActiveRecruit().UseMoveKey(map, move, i);
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        #endregion
                                    }
                                    break;
                                default:
                                    {
                                        Scripting.ScriptManager.InvokeSub("QuestionResult", client, id, parse[1]);
                                    }
                                    break;
                            }
                        }
                        break;
                    case "checkcommands":
                        if (!client.Player.Dead)
                        {
                            Scripting.ScriptManager.InvokeSub("Commands", client, CommandProcessor.ParseCommand(parse[1].Trim()));
                        }
                        break;
                    case "reloadscripts":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                            }
                            else
                            {
                                Scripting.ScriptManager.Reload();
                                Messenger.PlayerMsg(client, "Scripts reloaded!", Text.Yellow);
                            }
                        }
                        break;
                    #endregion
                    #region Tile Checks
                    case "buysprite":
                        {
                            IMap map = client.Player.GetCurrentMap();
                            if (map.Tile[client.Player.X, client.Player.Y].Type != Enums.TileType.SpriteChange)
                            {
                                Messenger.PlayerMsg(client, "You need to be on a sprite tile to buy it!", Text.BrightRed);
                                return;
                            }

                            if (map.Tile[client.Player.X, client.Player.Y].Data2 == 0)
                            {
                                client.Player.GetActiveRecruit().SetSpecies(map.Tile[client.Player.X, client.Player.Y].Data1);
                                Messenger.SendStats(client);
                                Messenger.SendInventory(client);
                                Messenger.SendActiveTeam(client);
                                Messenger.SendPlayerData(client);
                                return;
                            }

                            for (int i = 0; i <= client.Player.MaxInv; i++)
                            {
                                if (client.Player.Inventory[i].Num == map.Tile[client.Player.X, client.Player.Y].Data2)
                                {
                                    if (ItemManager.Items[client.Player.Inventory[i].Num].Type == Enums.ItemType.Currency)
                                    {
                                        if (client.Player.Inventory[i].Amount >= map.Tile[client.Player.X, client.Player.Y].Data3)
                                        {
                                            client.Player.TakeItemSlot(i, map.Tile[client.Player.X, client.Player.Y].Data3, true);
                                            Messenger.PlayerMsg(client, "You have bought a new sprite!", Text.BrightGreen);
                                            client.Player.GetActiveRecruit().SetSpecies(map.Tile[client.Player.X, client.Player.Y].Data1);
                                            Messenger.SendStats(client);
                                            //Messenger.SendDataToMap(client.Player.mMap, "checksprite" + TcpManager.SEP_CHAR + client.ToString() + TcpManager.SEP_CHAR + client.Player.GetActiveChar().mSprite.ToString() + TcpManager.SEP_CHAR + TcpManager.END_CHAR);
                                            Messenger.SendInventory(client);
                                            Messenger.SendActiveTeam(client);
                                            Messenger.SendPlayerData(client);
                                        }
                                    }
                                    else
                                    {
                                        if (client.Player.GetItemSlotHolder(i) == -1)
                                        {
                                            client.Player.TakeItemSlot(i, 1, true);
                                            Messenger.PlayerMsg(client, "You have bought a new sprite!", Text.BrightGreen);
                                            client.Player.GetActiveRecruit().SetSpecies(map.Tile[client.Player.X, client.Player.Y].Data1);
                                            Messenger.SendStats(client);
                                            //Messenger.SendDataToMap(client.Player.mMap, "checksprite" + TcpManager.SEP_CHAR + client.ToString() + TcpManager.SEP_CHAR + client.Player.GetActiveChar().mSprite.ToString() + TcpManager.SEP_CHAR + TcpManager.END_CHAR);
                                            Messenger.SendInventory(client);
                                            Messenger.SendActiveTeam(client);
                                            Messenger.SendPlayerData(client);
                                        }
                                    }
                                    if (client.Player.GetItemSlotHolder(i) == -1)
                                    {
                                        return;
                                    }
                                }
                            }

                            Messenger.PlayerMsg(client, "You dont have enough to buy this sprite!", Text.BrightRed);
                        }
                        break;
                    case "buyhouse":
                        {
                            // TODO: Remake "buyhouse" packet processor
                            //IMap map;
                            //if (client.Player.Map != -2) {
                            //    map = MapManager.Maps[client.Player.Map];
                            //} else {
                            //    Messenger.PlayerMsg(client, "You can't buy an instanced map!", Text.BrightRed);
                            //    return;
                            //}
                            //if (map.Tile[client.Player.X, client.Player.Y].Type != Enums.TileType.House) {
                            //    Messenger.PlayerMsg(client, "You need to be on a house tile to buy it!", Text.BrightRed);
                            //    return;
                            //}

                            //if (map.Tile[client.Player.X, client.Player.Y].Data1 == 0) {
                            //    Messenger.PlayerMsg(client, "You have bought a new house!", Text.BrightGreen);
                            //    map.Owner = client.Player.Name;
                            //    map.Name = client.Player.Name + "'s House";
                            //    map.Revision = map.Revision + 1;
                            //    map.Save();
                            //    //MapManager.SaveMap(map.MapNum);
                            //    Messenger.SendDataToMap(map.MapID, TcpPacket.CreatePacket("checkformap", map.MapID.ToString(), map.Revision.ToString()));
                            //    return;
                            //}

                            //for (int i = 1; i <= Constants.MAX_INV; i++) {
                            //    if (client.Player.Inventory[i].Num == map.Tile[client.Player.X, client.Player.Y].Data1) {
                            //        if (ItemManager.Items[client.Player.Inventory[i].Num].Type == Enums.ItemType.Currency) {
                            //            if (client.Player.Inventory[i].Val >= map.Tile[client.Player.X, client.Player.Y].Data2) {
                            //                client.Player.Inventory[i].Val -= map.Tile[client.Player.X, client.Player.Y].Data2;
                            //                if (client.Player.Inventory[i].Val <= 0) {
                            //                    client.Player.Inventory[i].Val = 0;
                            //                }
                            //                Messenger.PlayerMsg(client, "You have bought a new house!", Text.BrightGreen);
                            //                map.Owner = client.Player.Name;
                            //                map.Name = client.Player.Name + "'s House";
                            //                map.Revision = map.Revision + 1;
                            //                map.Save();
                            //                //MapManager.SaveMap(map.MapNum);
                            //                Messenger.SendDataToMap(map.MapNum, TcpPacket.CreatePacket("CHECKFORMAP", map.MapNum.ToString(), map.Revision.ToString()));
                            //                Messenger.SendInventory(client);
                            //            }
                            //        } else {
                            //            if (client.Player.Weapon != i & client.Player.Weapon != i & client.Player.Shield != i & client.Player.Helmet != i & client.Player.Legs != i & client.Player.Ring != i & client.Player.Necklace != i) {
                            //                client.Player.Inventory[i].Num = 0;
                            //                Messenger.PlayerMsg(client, "You now own a new house!", Text.BrightGreen);
                            //                map.Owner = client.Player.Name;
                            //                map.Name = client.Player.Name + "'s House";
                            //                map.Revision = map.Revision + 1;
                            //                MapManager.SaveMap(map.MapNum);
                            //                Messenger.SendDataToMap(map.MapNum, TcpPacket.CreatePacket("CHECKFORMAP", map.MapNum.ToString(), map.Revision.ToString()));
                            //                Messenger.SendInventory(client);
                            //            }
                            //        }
                            //        if (client.Player.Weapon != i & client.Player.Weapon != i & client.Player.Shield != i & client.Player.Helmet != i & client.Player.Legs != i & client.Player.Ring != i & client.Player.Necklace != i) {
                            //            return;
                            //        }
                            //    }
                            //}

                            //Messenger.PlayerMsg(client, "You dont have enough to buy this house!", Text.BrightRed);
                        }
                        break;
                    #endregion
                    #region Story
                    case "needstory":
                        {
                            if (parse[1] == "yes")
                            {
                                Messenger.SendUpdateStoryTo(client, parse[2].ToInt());
                                if (client.Player.SegmentToStart > -1)
                                {
                                    Messenger.SendStartStoryTo(client, parse[2].ToInt(), client.Player.SegmentToStart);
                                }
                                else
                                {
                                    Messenger.SendStartStoryTo(client, parse[2].ToInt());
                                }
                            }
                            else if (parse[1] == "no")
                            {
                                if (client.Player.SegmentToStart > -1)
                                {
                                    Messenger.SendStartStoryTo(client, parse[2].ToInt(), client.Player.SegmentToStart);
                                }
                                else
                                {
                                    Messenger.SendStartStoryTo(client, parse[2].ToInt());
                                }
                            }
                        }
                        break;
                    case "updatesegment":
                        {
                            client.Player.CurrentSegment = parse[1].ToInt(-1);
                        }
                        break;
                    case "actonaction":
                        {
                            int storyNum = -1;
                            if (client.Player.CurrentChapter != null && !string.IsNullOrEmpty(client.Player.CurrentChapter.ID))
                            {
                                storyNum = client.Player.CurrentChapter.ID.ToInt(-1);
                            }
                            if (client.Player.CurrentChapter != null)
                            {
                                StorySegment story = client.Player.CurrentChapter.Segments[client.Player.CurrentSegment];
                                switch (story.Action)
                                {
                                    case Enums.StoryAction.RunScript:
                                        {
                                            Stories.StoryManager.RunScript(client, story.Parameters.GetValue("ScriptIndex").ToInt(),
                                                story.Parameters.GetValue("ScriptParam1"),
                                                story.Parameters.GetValue("ScriptParam2"),
                                                story.Parameters.GetValue("ScriptParam3"),
                                                story.Parameters.GetValue("Pause").ToBool());
                                        }
                                        break;
                                    case Enums.StoryAction.Padlock:
                                        {
                                            if (storyNum > -1)
                                            {
                                                if (story.Parameters.GetValue("State") == "Unlock")
                                                {
                                                    client.Player.SetStoryState(storyNum, false);
                                                }
                                                else if (story.Parameters.GetValue("State") == "Lock")
                                                {
                                                    client.Player.SetStoryState(storyNum, true);
                                                }
                                            }
                                        }
                                        break;
                                    case Enums.StoryAction.Warp:
                                        {
                                            int X, Y;
                                            if (story.Parameters.GetValue("X") == "-1")
                                            {
                                                X = client.Player.X;
                                            }
                                            else
                                            {
                                                int tmpX = story.Parameters.GetValue("X").ToInt(-1);
                                                if (tmpX > -1)
                                                {
                                                    X = tmpX;
                                                }
                                                else
                                                {
                                                    X = client.Player.X;
                                                }
                                            }
                                            if (story.Parameters.GetValue("Y") == "-1")
                                            {
                                                Y = client.Player.Y;
                                            }
                                            else
                                            {
                                                int tmpY = story.Parameters.GetValue("Y").ToInt(-1);
                                                if (tmpY > -1)
                                                {
                                                    Y = tmpY;
                                                }
                                                else
                                                {
                                                    Y = client.Player.Y;
                                                }
                                            }
                                            Messenger.PlayerWarp(client, story.Parameters.GetValue("MapID"), X, Y);
                                        }
                                        break;
                                }
                            }
                        }
                        break;
                    case "chaptercomplete":
                        {
                            client.Player.CurrentChapter = null;
                            client.Player.CurrentSegment = -1;
                            if (client.Player.StoryPlaybackCache.Count > 0)
                            {
                                if (!string.IsNullOrEmpty(client.Player.StoryPlaybackCache[0].ID) && client.Player.StoryPlaybackCache[0].ID.IsNumeric())
                                {
                                    StoryManager.PlayStory(client, client.Player.StoryPlaybackCache[0].ID.ToInt());
                                }
                                else
                                {
                                    StoryManager.PlayStory(client, client.Player.StoryPlaybackCache[0]);
                                }
                                client.Player.StoryPlaybackCache.RemoveAt(0);
                            }
                        }
                        break;
                    case "storyloadingcomplete":
                        {
                            client.Player.LoadingStory = false;
                        }
                        break;
                    #endregion
                    #region Editors

                    #region Random Dungeons
                    case "requesteditrdungeon":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            Messenger.SendRDungeonEditor(client);
                        }
                        break;
                    case "addnewrdungeon":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            Messenger.SendAddRDungeonToAll(RDungeonManager.AddRDungeon());
                        }
                        break;
                    case "editrdungeon":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            int n = parse[1].ToInt();
                            if (n < 0 || n > RDungeonManager.RDungeons.Count - 1)
                            {
                                Messenger.PlayerMsg(client, "Invalid dungeon client", Text.BrightRed);
                                return;
                            }

                            Messenger.SendEditRDungeonTo(client, n);
                        }
                        break;
                    case "saverdungeon":
                        {//adjust to new variables
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            int z = parse[1].ToInt();

                            RDungeonManager.RDungeons[z].DungeonName = parse[2];
                            RDungeonManager.RDungeons[z].Direction = (Enums.Direction)parse[3].ToInt();
                            int maxFloors = parse[4].ToInt();
                            RDungeonManager.RDungeons[z].Recruitment = parse[5].ToBool();
                            RDungeonManager.RDungeons[z].Exp = parse[6].ToBool();
                            RDungeonManager.RDungeons[z].WindTimer = parse[7].ToInt();
                            RDungeonManager.RDungeons[z].DungeonIndex = parse[8].ToInt();
                            int n = 9;
                            RDungeonManager.RDungeons[z].Floors.Clear();
                            for (int i = 0; i < maxFloors; i++)
                            {
                                RDungeonManager.RDungeons[z].Floors.Add(new RDungeonFloor());
                                RDungeonManager.RDungeons[z].Floors[i].Options.TrapMin = parse[n].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.TrapMax = parse[n + 1].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.ItemMin = parse[n + 2].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.ItemMax = parse[n + 3].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.Intricacy = parse[n + 4].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.RoomWidthMin = parse[n + 5].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.RoomWidthMax = parse[n + 6].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.RoomLengthMin = parse[n + 7].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.RoomLengthMax = parse[n + 8].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.HallTurnMin = parse[n + 9].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.HallTurnMax = parse[n + 10].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.HallVarMin = parse[n + 11].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.HallVarMax = parse[n + 12].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.WaterFrequency = parse[n + 13].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.Craters = parse[n + 14].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.CraterMinLength = parse[n + 15].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.CraterMaxLength = parse[n + 16].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.CraterFuzzy = parse[n + 17].ToBool();
                                RDungeonManager.RDungeons[z].Floors[i].Options.MinChambers = parse[n + 18].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Options.MaxChambers = parse[n + 19].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Darkness = parse[n + 20].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GoalType = (Enums.RFloorGoalType)parse[n + 21].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GoalMap = parse[n + 22].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GoalX = parse[n + 23].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GoalY = parse[n + 24].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].Music = parse[n + 25];

                                n += 26;

                                RDungeonManager.RDungeons[z].Floors[i].StairsX = parse[n].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].StairsSheet = parse[n + 1].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mGroundX = parse[n + 2].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mGroundSheet = parse[n + 3].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mTopLeftX = parse[n + 4].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopLeftSheet = parse[n + 5].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopCenterX = parse[n + 6].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopCenterSheet = parse[n + 7].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopRightX = parse[n + 8].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopRightSheet = parse[n + 9].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mCenterLeftX = parse[n + 10].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterLeftSheet = parse[n + 11].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterCenterX = parse[n + 12].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterCenterSheet = parse[n + 13].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterRightX = parse[n + 14].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterRightSheet = parse[n + 15].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mBottomLeftX = parse[n + 16].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomLeftSheet = parse[n + 17].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomCenterX = parse[n + 18].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomCenterSheet = parse[n + 19].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomRightX = parse[n + 20].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomRightSheet = parse[n + 21].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopLeftX = parse[n + 22].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopLeftSheet = parse[n + 23].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomLeftX = parse[n + 24].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomLeftSheet = parse[n + 25].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopRightX = parse[n + 26].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopRightSheet = parse[n + 27].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomRightX = parse[n + 28].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomRightSheet = parse[n + 29].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mIsolatedWallX = parse[n + 30].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mIsolatedWallSheet = parse[n + 31].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnTopX = parse[n + 32].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnTopSheet = parse[n + 33].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnCenterX = parse[n + 34].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnCenterSheet = parse[n + 35].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnBottomX = parse[n + 36].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnBottomSheet = parse[n + 37].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mRowLeftX = parse[n + 38].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowLeftSheet = parse[n + 39].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowCenterX = parse[n + 40].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowCenterSheet = parse[n + 41].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowRightX = parse[n + 42].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowRightSheet = parse[n + 43].ToInt();

                                n += 44;

                                RDungeonManager.RDungeons[z].Floors[i].mGroundAltX = parse[n].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mGroundAltSheet = parse[n + 1].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mGroundAlt2X = parse[n + 2].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mGroundAlt2Sheet = parse[n + 3].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mTopLeftAltX = parse[n + 4].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopLeftAltSheet = parse[n + 5].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopCenterAltX = parse[n + 6].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopCenterAltSheet = parse[n + 7].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopRightAltX = parse[n + 8].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mTopRightAltSheet = parse[n + 9].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mCenterLeftAltX = parse[n + 10].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterLeftAltSheet = parse[n + 11].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterCenterAltX = parse[n + 12].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterCenterAltSheet = parse[n + 13].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterCenterAlt2X = parse[n + 14].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterCenterAlt2Sheet = parse[n + 15].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterRightAltX = parse[n + 16].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mCenterRightAltSheet = parse[n + 17].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mBottomLeftAltX = parse[n + 18].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomLeftAltSheet = parse[n + 19].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomCenterAltX = parse[n + 20].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomCenterAltSheet = parse[n + 21].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomRightAltX = parse[n + 22].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mBottomRightAltSheet = parse[n + 23].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopLeftAltX = parse[n + 24].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopLeftAltSheet = parse[n + 25].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomLeftAltX = parse[n + 26].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomLeftAltSheet = parse[n + 27].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopRightAltX = parse[n + 28].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerTopRightAltSheet = parse[n + 29].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomRightAltX = parse[n + 30].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mInnerBottomRightAltSheet = parse[n + 31].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mIsolatedWallAltX = parse[n + 32].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mIsolatedWallAltSheet = parse[n + 33].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnTopAltX = parse[n + 34].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnTopAltSheet = parse[n + 35].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnCenterAltX = parse[n + 36].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnCenterAltSheet = parse[n + 37].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnBottomAltX = parse[n + 38].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mColumnBottomAltSheet = parse[n + 39].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mRowLeftAltX = parse[n + 40].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowLeftAltSheet = parse[n + 41].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowCenterAltX = parse[n + 42].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowCenterAltSheet = parse[n + 43].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowRightAltX = parse[n + 44].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mRowRightAltSheet = parse[n + 45].ToInt();

                                n += 46;

                                RDungeonManager.RDungeons[z].Floors[i].mWaterX = parse[n].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mWaterSheet = parse[n + 1].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mWaterAnimX = parse[n + 2].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mWaterAnimSheet = parse[n + 3].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopLeftX = parse[n + 4].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopLeftSheet = parse[n + 5].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopRightX = parse[n + 6].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopRightSheet = parse[n + 7].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomRightX = parse[n + 8].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomRightSheet = parse[n + 9].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomLeftX = parse[n + 10].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomLeftSheet = parse[n + 11].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalForwardX = parse[n + 12].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalForwardSheet = parse[n + 13].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalBackX = parse[n + 14].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalBackSheet = parse[n + 15].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopX = parse[n + 16].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopSheet = parse[n + 17].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreRightX = parse[n + 18].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreRightSheet = parse[n + 19].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomX = parse[n + 20].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomSheet = parse[n + 21].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreLeftX = parse[n + 22].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreLeftSheet = parse[n + 23].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreVerticalX = parse[n + 24].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreVerticalSheet = parse[n + 25].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreHorizontalX = parse[n + 26].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreHorizontalSheet = parse[n + 27].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopLeftX = parse[n + 28].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopLeftSheet = parse[n + 29].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopRightX = parse[n + 30].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopRightSheet = parse[n + 31].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomRightX = parse[n + 32].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomRightSheet = parse[n + 33].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomLeftX = parse[n + 34].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomLeftSheet = parse[n + 35].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopX = parse[n + 36].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopSheet = parse[n + 37].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerRightX = parse[n + 38].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerRightSheet = parse[n + 39].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomX = parse[n + 40].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomSheet = parse[n + 41].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerLeftX = parse[n + 42].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerLeftSheet = parse[n + 43].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreSurroundedX = parse[n + 44].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreSurroundedSheet = parse[n + 45].ToInt();

                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopLeftAnimX = parse[n + 46].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopLeftAnimSheet = parse[n + 47].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopRightAnimX = parse[n + 48].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopRightAnimSheet = parse[n + 49].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomRightAnimX = parse[n + 50].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomRightAnimSheet = parse[n + 51].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomLeftAnimX = parse[n + 52].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomLeftAnimSheet = parse[n + 53].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalForwardAnimX = parse[n + 54].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalForwardAnimSheet = parse[n + 55].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalBackAnimX = parse[n + 56].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreDiagonalBackAnimSheet = parse[n + 57].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopAnimX = parse[n + 58].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreTopAnimSheet = parse[n + 59].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreRightAnimX = parse[n + 60].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreRightAnimSheet = parse[n + 61].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomAnimX = parse[n + 62].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreBottomAnimSheet = parse[n + 63].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreLeftAnimX = parse[n + 64].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreLeftAnimSheet = parse[n + 65].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreVerticalAnimX = parse[n + 66].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreVerticalAnimSheet = parse[n + 67].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreHorizontalAnimX = parse[n + 68].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreHorizontalAnimSheet = parse[n + 69].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopLeftAnimX = parse[n + 70].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopLeftAnimSheet = parse[n + 71].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopRightAnimX = parse[n + 72].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopRightAnimSheet = parse[n + 73].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomRightAnimX = parse[n + 74].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomRightAnimSheet = parse[n + 75].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomLeftAnimX = parse[n + 76].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomLeftAnimSheet = parse[n + 77].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopAnimX = parse[n + 78].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerTopAnimSheet = parse[n + 79].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerRightAnimX = parse[n + 80].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerRightAnimSheet = parse[n + 81].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomAnimX = parse[n + 82].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerBottomAnimSheet = parse[n + 83].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerLeftAnimX = parse[n + 84].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreInnerLeftAnimSheet = parse[n + 85].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreSurroundedAnimX = parse[n + 86].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].mShoreSurroundedAnimSheet = parse[n + 87].ToInt();

                                n += 88;

                                RDungeonManager.RDungeons[z].Floors[i].GroundTile.Type = (Enums.TileType)parse[n].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GroundTile.Data1 = parse[n + 1].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GroundTile.Data2 = parse[n + 2].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GroundTile.Data3 = parse[n + 3].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].GroundTile.String1 = parse[n + 4];
                                RDungeonManager.RDungeons[z].Floors[i].GroundTile.String2 = parse[n + 5];
                                RDungeonManager.RDungeons[z].Floors[i].GroundTile.String3 = parse[n + 6];

                                RDungeonManager.RDungeons[z].Floors[i].HallTile.Type = (Enums.TileType)parse[n + 7].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].HallTile.Data1 = parse[n + 8].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].HallTile.Data2 = parse[n + 9].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].HallTile.Data3 = parse[n + 10].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].HallTile.String1 = parse[n + 11];
                                RDungeonManager.RDungeons[z].Floors[i].HallTile.String2 = parse[n + 12];
                                RDungeonManager.RDungeons[z].Floors[i].HallTile.String3 = parse[n + 13];

                                RDungeonManager.RDungeons[z].Floors[i].WaterTile.Type = (Enums.TileType)parse[n + 14].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WaterTile.Data1 = parse[n + 15].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WaterTile.Data2 = parse[n + 16].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WaterTile.Data3 = parse[n + 17].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WaterTile.String1 = parse[n + 18];
                                RDungeonManager.RDungeons[z].Floors[i].WaterTile.String2 = parse[n + 19];
                                RDungeonManager.RDungeons[z].Floors[i].WaterTile.String3 = parse[n + 20];

                                RDungeonManager.RDungeons[z].Floors[i].WallTile.Type = (Enums.TileType)parse[n + 21].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WallTile.Data1 = parse[n + 22].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WallTile.Data2 = parse[n + 23].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WallTile.Data3 = parse[n + 24].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].WallTile.String1 = parse[n + 25];
                                RDungeonManager.RDungeons[z].Floors[i].WallTile.String2 = parse[n + 26];
                                RDungeonManager.RDungeons[z].Floors[i].WallTile.String3 = parse[n + 27];

                                RDungeonManager.RDungeons[z].Floors[i].NpcSpawnTime = parse[n + 28].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].NpcMin = parse[n + 29].ToInt();
                                RDungeonManager.RDungeons[z].Floors[i].NpcMax = parse[n + 30].ToInt();

                                n += 31;

                                RDungeonManager.RDungeons[z].Floors[i].Items.Clear();
                                for (int item = 0; item < parse[n].ToInt(); item++)
                                {
                                    RDungeonItem newItem = new RDungeonItem();
                                    newItem.ItemNum = parse[n + item * 10 + 1].ToInt();
                                    newItem.MinAmount = parse[n + item * 10 + 2].ToInt();
                                    newItem.MaxAmount = parse[n + item * 10 + 3].ToInt();
                                    newItem.AppearanceRate = parse[n + item * 10 + 4].ToInt();
                                    newItem.StickyRate = parse[n + item * 10 + 5].ToInt();
                                    newItem.Tag = parse[n + item * 10 + 6];
                                    newItem.Hidden = parse[n + item * 10 + 7].ToBool();
                                    newItem.OnGround = parse[n + item * 10 + 8].ToBool();
                                    newItem.OnWater = parse[n + item * 10 + 9].ToBool();
                                    newItem.OnWall = parse[n + item * 10 + 10].ToBool();

                                    RDungeonManager.RDungeons[z].Floors[i].Items.Add(newItem);
                                }
                                n += RDungeonManager.RDungeons[z].Floors[i].Items.Count * 10 + 1;

                                RDungeonManager.RDungeons[z].Floors[i].Npcs.Clear();
                                for (int npc = 0; npc < parse[n].ToInt(); npc++)
                                {
                                    MapNpcPreset newNpc = new MapNpcPreset();
                                    newNpc.NpcNum = parse[n + npc * 7 + 1].ToInt();
                                    newNpc.MinLevel = parse[n + npc * 7 + 2].ToInt();
                                    newNpc.MaxLevel = parse[n + npc * 7 + 3].ToInt();
                                    newNpc.AppearanceRate = parse[n + npc * 7 + 4].ToInt();
                                    newNpc.StartStatus = (Enums.StatusAilment)parse[n + npc * 7 + 5].ToInt();
                                    newNpc.StartStatusCounter = parse[n + npc * 7 + 6].ToInt();
                                    newNpc.StartStatusChance = parse[n + npc * 7 + 7].ToInt();

                                    RDungeonManager.RDungeons[z].Floors[i].Npcs.Add(newNpc);
                                }
                                n += RDungeonManager.RDungeons[z].Floors[i].Npcs.Count * 7 + 1;

                                RDungeonManager.RDungeons[z].Floors[i].SpecialTiles.Clear();
                                for (int traps = 0; traps < parse[n].ToInt(); traps++)
                                {
                                    RDungeonTrap newTile = new RDungeonTrap();
                                    newTile.Type = (Enums.TileType)parse[n + traps * 29 + 1].ToInt();
                                    newTile.Data1 = parse[n + traps * 29 + 2].ToInt();
                                    newTile.Data2 = parse[n + traps * 29 + 3].ToInt();
                                    newTile.Data3 = parse[n + traps * 29 + 4].ToInt();
                                    newTile.String1 = parse[n + traps * 29 + 5];
                                    newTile.String2 = parse[n + traps * 29 + 6];
                                    newTile.String3 = parse[n + traps * 29 + 7];
                                    newTile.Ground = parse[n + traps * 29 + 8].ToInt();
                                    newTile.GroundSet = parse[n + traps * 29 + 9].ToInt();
                                    newTile.GroundAnim = parse[n + traps * 29 + 10].ToInt();
                                    newTile.GroundAnimSet = parse[n + traps * 29 + 11].ToInt();
                                    newTile.Mask = parse[n + traps * 29 + 12].ToInt();
                                    newTile.MaskSet = parse[n + traps * 29 + 13].ToInt();
                                    newTile.Anim = parse[n + traps * 29 + 14].ToInt();
                                    newTile.AnimSet = parse[n + traps * 29 + 15].ToInt();
                                    newTile.Mask2 = parse[n + traps * 29 + 16].ToInt();
                                    newTile.Mask2Set = parse[n + traps * 29 + 17].ToInt();
                                    newTile.M2Anim = parse[n + traps * 29 + 18].ToInt();
                                    newTile.M2AnimSet = parse[n + traps * 29 + 19].ToInt();
                                    newTile.Fringe = parse[n + traps * 29 + 20].ToInt();
                                    newTile.FringeSet = parse[n + traps * 29 + 21].ToInt();
                                    newTile.FAnim = parse[n + traps * 29 + 22].ToInt();
                                    newTile.FAnimSet = parse[n + traps * 29 + 23].ToInt();
                                    newTile.Fringe2 = parse[n + traps * 29 + 24].ToInt();
                                    newTile.Fringe2Set = parse[n + traps * 29 + 25].ToInt();
                                    newTile.F2Anim = parse[n + traps * 29 + 26].ToInt();
                                    newTile.F2AnimSet = parse[n + traps * 29 + 27].ToInt();
                                    newTile.RDungeonMapValue = parse[n + traps * 29 + 28].ToInt();

                                    newTile.AppearanceRate = parse[n + traps * 29 + 29].ToInt();

                                    RDungeonManager.RDungeons[z].Floors[i].SpecialTiles.Add(newTile);

                                }
                                n += RDungeonManager.RDungeons[z].Floors[i].SpecialTiles.Count * 29 + 1;

                                RDungeonManager.RDungeons[z].Floors[i].Weather.Clear();
                                for (int weather = 0; weather < parse[n].ToInt(); weather++)
                                {
                                    RDungeonManager.RDungeons[z].Floors[i].Weather.Add((Enums.Weather)parse[n + 1 + weather].ToInt());

                                }
                                n += RDungeonManager.RDungeons[z].Floors[i].Weather.Count + 1;

                                RDungeonManager.RDungeons[z].Floors[i].Options.Chambers.Clear();
                                for (int chamber = 0; chamber < parse[n].ToInt(); chamber++)
                                {
                                    RDungeonPresetChamber newChamber = new RDungeonPresetChamber();
                                    newChamber.ChamberNum = parse[n + chamber * 4 + 1].ToInt();
                                    newChamber.String1 = parse[n + chamber * 4 + 2];
                                    newChamber.String2 = parse[n + chamber * 4 + 3];
                                    newChamber.String3 = parse[n + chamber * 4 + 4];

                                    RDungeonManager.RDungeons[z].Floors[i].Options.Chambers.Add(newChamber);
                                }
                                n += RDungeonManager.RDungeons[z].Floors[i].Options.Chambers.Count * 4 + 1;

                            }
                            Messenger.SendUpdateRDungeonToAll(z);
                            RDungeonManager.SaveRDungeon(z);

                        }
                        break;
                    #endregion
                    #region Maps
                    case "mapreportrequest":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }
                            TcpPacket packet = new TcpPacket("mapreport");
                            packet.AppendParameter(MapManager.StandardMapCount);
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data))
                            {
                                for (int i = 1; i <= MapManager.StandardMapCount; i++)
                                {
                                    //packet.AppendParameter(MapManager.Maps[i].Name);
                                    packet.AppendParameter(DataManager.Maps.MapDataManager.GetMapName(dbConnection.Database, MapManager.GenerateMapID(i)));
                                }
                            }

                            Messenger.SendDataTo(client, packet);
                        }
                        break;
                    case "requesteditmap":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                        {
                            Messenger.HackingAttempt(client, "Admin cloning");
                            return;
                        }
                        if (client.Player.Map.MapType == Enums.MapType.Instanced)
                        {
                            int mapBase = ((InstancedMap)client.Player.Map).MapBase;
                            if (mapBase > 0)
                            {
                                client.Player.BeginUninstancedWarp();
                                Messenger.PlayerWarp(client, mapBase, client.Player.X, client.Player.Y);
                                client.Player.EndUninstancedWarp();
                                Messenger.PlayerMsg(client, "You have been warped to the original map to edit it!", Text.BrightBlue);
                                return;
                            }
                        }
                        if (client.Player.Map.MapType != Enums.MapType.Standard && client.Player.Map.MapType != Enums.MapType.House)
                        {
                            Messenger.PlayerMsg(client, "You can't edit a non-standard map!", Text.BrightRed);
                            return;
                        }
                        client.Player.InMapEditor = true;
                        Messenger.SendDataTo(client, TcpPacket.CreatePacket("editmap"));
                        Messenger.SendMapLatestPropertiesTo(client);
                        break;
                    case "requestedithouse":
                        {
                            if (client.Player.Map.MapType == Enums.MapType.House)
                            {
                                House house = client.Player.Map as House;
                                if (house.OwnerID != client.Player.CharID)
                                {
                                    Messenger.PlayerMsg(client, "This is not your house!", Text.BrightRed);
                                    return;
                                }
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("edithouse"));
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "This is not a house!", Text.BrightRed);
                            }
                        }
                        break;
                    case "mapdata":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                if (client.Player.Map.MapType == Enums.MapType.House)
                                {
                                    if (((House)client.Player.Map).OwnerID != client.Player.CharID)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            if (client.Player.Map.MapType != Enums.MapType.Standard && client.Player.Map.MapType != Enums.MapType.House)
                            {
                                Messenger.PlayerMsg(client, "You can't edit a non-standard map!", Text.BrightRed);
                                return;
                            }

                            IMap map = null;
                            string mapID = "s0";
                            int n = 0;
                            int X = 0;
                            int Y = 0;
                            n = 1;

                            mapID = client.Player.MapID;
                            if (mapID != parse[n])
                            {
                                Messenger.PlayerMsg(client, "Error Saving: Incorrect Map [Error 3]", Text.BrightRed);
                                return;
                            }
                            if (client.Player.Map.MapType == Enums.MapType.Standard)
                            {
                                map = new Map(new DataManager.Maps.Map(mapID));
                            }
                            else if (client.Player.Map.MapType == Enums.MapType.House)
                            {
                                House houseMap = client.Player.Map as House;

                                DataManager.Maps.HouseMap newHouseMap = new DataManager.Maps.HouseMap(MapManager.GenerateHouseID(houseMap.OwnerID, houseMap.Room));
                                newHouseMap.Owner = houseMap.OwnerID;
                                newHouseMap.Room = houseMap.Room;
                                newHouseMap.StartX = ((House)client.Player.Map).StartX;
                                newHouseMap.StartY = ((House)client.Player.Map).StartY;
                                map = new House(newHouseMap);

                            }
                            map.IsSaving = true;

                            int revision = MapManager.RetrieveActiveMap(mapID).Revision;
                            map.Name = parse[n + 1];
                            map.Revision = revision + 1;
                            map.Moral = (Enums.MapMoral)parse[n + 3].ToInt();
                            map.Up = parse[n + 4].ToInt();
                            map.Down = parse[n + 5].ToInt();
                            map.Left = parse[n + 6].ToInt();
                            map.Right = parse[n + 7].ToInt();
                            map.Music = parse[n + 8];
                            map.Indoors = parse[n + 9].ToBool();
                            map.Weather = (Enums.Weather)parse[n + 10].ToInt();
                            map.MaxX = parse[n + 11].ToInt();
                            map.MaxY = parse[n + 12].ToInt();
                            map.OriginalDarkness = parse[n + 13].ToInt();
                            map.HungerEnabled = parse[n + 14].ToBool();
                            map.RecruitEnabled = parse[n + 15].ToBool();
                            map.ExpEnabled = parse[n + 16].ToBool();
                            map.TimeLimit = parse[n + 17].ToInt();
                            map.MinNpcs = parse[n + 18].ToInt();
                            map.MaxNpcs = parse[n + 19].ToInt();
                            map.NpcSpawnTime = parse[n + 20].ToInt();

                            if (map.MapType == Enums.MapType.Standard)
                            {
                                ((Map)map).Instanced = parse[n + 21].ToBool();
                            }

                            map.Tile = new TileCollection(map.BaseMap, map.MaxX, map.MaxY);

                            n += 22;

                            for (Y = 0; Y <= map.MaxY; Y++)
                            {
                                for (X = 0; X <= map.MaxX; X++)
                                {
                                    map.Tile[X, Y].Ground = parse[n].ToInt();
                                    map.Tile[X, Y].GroundAnim = parse[n + 1].ToInt();
                                    map.Tile[X, Y].Mask = parse[n + 2].ToInt();
                                    map.Tile[X, Y].Anim = parse[n + 3].ToInt();
                                    map.Tile[X, Y].Mask2 = parse[n + 4].ToInt();
                                    map.Tile[X, Y].M2Anim = parse[n + 5].ToInt();
                                    map.Tile[X, Y].Fringe = parse[n + 6].ToInt();
                                    map.Tile[X, Y].FAnim = parse[n + 7].ToInt();
                                    map.Tile[X, Y].Fringe2 = parse[n + 8].ToInt();
                                    map.Tile[X, Y].F2Anim = parse[n + 9].ToInt();
                                    map.Tile[X, Y].Type = (Enums.TileType)parse[n + 10].ToInt();
                                    map.Tile[X, Y].Data1 = parse[n + 11].ToInt();
                                    map.Tile[X, Y].Data2 = parse[n + 12].ToInt();
                                    map.Tile[X, Y].Data3 = parse[n + 13].ToInt();
                                    map.Tile[X, Y].String1 = parse[n + 14];
                                    map.Tile[X, Y].String2 = parse[n + 15];
                                    map.Tile[X, Y].String3 = parse[n + 16];
                                    map.Tile[X, Y].RDungeonMapValue = parse[n + 17].ToInt();
                                    map.Tile[X, Y].GroundSet = parse[n + 18].ToInt();
                                    map.Tile[X, Y].GroundAnimSet = parse[n + 19].ToInt();
                                    map.Tile[X, Y].MaskSet = parse[n + 20].ToInt();
                                    map.Tile[X, Y].AnimSet = parse[n + 21].ToInt();
                                    map.Tile[X, Y].Mask2Set = parse[n + 22].ToInt();
                                    map.Tile[X, Y].M2AnimSet = parse[n + 23].ToInt();
                                    map.Tile[X, Y].FringeSet = parse[n + 24].ToInt();
                                    map.Tile[X, Y].FAnimSet = parse[n + 25].ToInt();
                                    map.Tile[X, Y].Fringe2Set = parse[n + 26].ToInt();
                                    map.Tile[X, Y].F2AnimSet = parse[n + 27].ToInt();
                                    n += 28;

                                    if (map.MapType == Enums.MapType.House)
                                    {
                                        if (map.Tile[X, Y].Type == Enums.TileType.Warp || map.Tile[X, Y].Type == Enums.TileType.Item)
                                        {
                                            Messenger.PlayerMsg(client, "Invalid map tile placed!", Text.BrightRed);
                                            return;
                                        }
                                    }
                                }
                            }

                            int npcCount = parse[n].ToInt();
                            n++;

                            for (X = 0; X < npcCount; X++)
                            {
                                MapNpcPreset newNpc = new MapNpcPreset();
                                newNpc.NpcNum = parse[n].ToInt();
                                newNpc.SpawnX = parse[n + 1].ToInt();
                                newNpc.SpawnY = parse[n + 2].ToInt();
                                newNpc.MinLevel = parse[n + 3].ToInt();
                                newNpc.MaxLevel = parse[n + 4].ToInt();
                                newNpc.AppearanceRate = parse[n + 5].ToInt();
                                newNpc.StartStatus = (Enums.StatusAilment)parse[n + 6].ToInt();
                                newNpc.StartStatusCounter = parse[n + 7].ToInt();
                                newNpc.StartStatusChance = parse[n + 8].ToInt();

                                map.Npc.Add(newNpc);
                                n += 9;
                            }

                            for (int i = 0; i < Constants.MAX_MAP_NPCS; i++)
                            {
                                map.ClearActiveNpc(i);
                            }

                            // Clear out it all
                            for (int i = 0; i < Constants.MAX_MAP_ITEMS; i++)
                            {
                                map.SpawnItemSlot(i, -1, 0, false, false, "", map.ActiveItem[i].X, map.ActiveItem[i].Y, null);
                                map.ClearActiveItem(i);
                            }

                            map.RemakePlayersList();
                            MapManager.UpdateActiveMap(mapID, map);
                            //MapManager.Maps[mapID] = map;
                            // Save the map
                            map.Save();
                            map.IsSaving = false;
                            // Respawn
                            map.SpawnItems();
                            map.SpawnNpcs();

                            // Refresh map for everyone online
                            foreach (Client i in map.GetClients())
                            {
                                if (i.IsPlaying())
                                {
                                    if (Ranks.IsAllowed(i, Enums.Rank.Mapper))
                                    {
                                        if (map.MapType == Enums.MapType.Standard)
                                        {
                                            Map standardMap = map as Map;
                                            if (standardMap != null)
                                            {
                                                Messenger.SendMapNameUpdate(i, standardMap.MapNum, standardMap.Name);
                                            }
                                        }
                                    }
                                    if (i.Player.MapID == map.MapID)
                                    {
                                        i.Player.InvalidateCachedMap();
                                        Messenger.SendCheckForMap(i);
                                    }
                                }
                            }
                        }
                        break;
                    case "scriptedtileinforequest":
                        {
                            Messenger.SendScriptedTileInfoTo(client, (string)Scripting.ScriptManager.InvokeFunction("ScriptedTileInfo", client, parse[1].ToInt()));
                        }
                        break;
                    case "scriptedsigninforequest":
                        {
                            Messenger.SendScriptedSignInfoTo(client, (string)Scripting.ScriptManager.InvokeFunction("ScriptedSignInfo", client, parse[1].ToInt()));
                        }
                        break;
                    case "mobilityinforequest":
                        {
                            Messenger.SendMobilityInfoTo(client, (string)Scripting.ScriptManager.InvokeFunction("MobilityInfo", client, parse[1].ToInt()));
                        }
                        break;
                    #endregion
                    #region Live Map Editor
                    case "exitmapeditor":
                        {
                            client.Player.InMapEditor = false;
                        }
                        break;
                    case "mapeditortileplaced":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                if (client.Player.Map.MapType == Enums.MapType.House)
                                {
                                    if (((House)client.Player.Map).OwnerID != client.Player.CharID)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            if (client.Player.Map.MapType != Enums.MapType.Standard && client.Player.Map.MapType != Enums.MapType.House)
                            {
                                Messenger.PlayerMsg(client, "You can't edit a non-standard map!", Text.BrightRed);
                                return;
                            }

                            int x = parse[1].ToInt();
                            int y = parse[2].ToInt();
                            int layer = parse[3].ToInt();
                            int set = parse[4].ToInt();
                            int tile = parse[5].ToInt();

                            IMap map = client.Player.Map;
                            foreach (Client mapper in map.GetClients())
                            {
                                // We only want to check the mappers
                                if (Ranks.IsAllowed(mapper, Enums.Rank.Mapper))
                                {
                                    if (mapper != client)
                                    {
                                        // We're on the same map...
                                        if (mapper.Player.InMapEditor)
                                        {
                                            // We have the map editor open...
                                            Messenger.SendLiveMapEditorTilePlacedData(mapper, x, y, layer, set, tile);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "mapeditorattribplaced":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                if (client.Player.Map.MapType == Enums.MapType.House)
                                {
                                    if (((House)client.Player.Map).OwnerID != client.Player.CharID)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            if (client.Player.Map.MapType != Enums.MapType.Standard && client.Player.Map.MapType != Enums.MapType.House)
                            {
                                Messenger.PlayerMsg(client, "You can't edit a non-standard map!", Text.BrightRed);
                                return;
                            }

                            int x = parse[1].ToInt();
                            int y = parse[2].ToInt();
                            int type = parse[3].ToInt();
                            int data1 = parse[4].ToInt();
                            int data2 = parse[5].ToInt();
                            int data3 = parse[6].ToInt();
                            string string1 = parse[7];
                            string string2 = parse[8];
                            string string3 = parse[9];
                            int dungeonValue = parse[10].ToInt();

                            IMap map = client.Player.Map;
                            foreach (Client mapper in map.GetClients())
                            {
                                // We only want to check the mappers
                                if (Ranks.IsAllowed(mapper, Enums.Rank.Mapper))
                                {
                                    if (mapper != client)
                                    {
                                        // We're on the same map...
                                        if (mapper.Player.InMapEditor)
                                        {
                                            // We have the map editor open...
                                            Messenger.SendLiveMapEditorAttributePlacedData(mapper, x, y, type, data1, data2, data3,
                                                string1, string2, string3, dungeonValue);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "mapeditorfilllayer":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                if (client.Player.Map.MapType == Enums.MapType.House)
                                {
                                    if (((House)client.Player.Map).OwnerID != client.Player.CharID)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            if (client.Player.Map.MapType != Enums.MapType.Standard && client.Player.Map.MapType != Enums.MapType.House)
                            {
                                Messenger.PlayerMsg(client, "You can't edit a non-standard map!", Text.BrightRed);
                                return;
                            }

                            int layer = parse[1].ToInt();
                            int set = parse[2].ToInt();
                            int tile = parse[3].ToInt();

                            IMap map = client.Player.Map;
                            foreach (Client mapper in map.GetClients())
                            {
                                // We only want to check the mappers
                                if (Ranks.IsAllowed(mapper, Enums.Rank.Mapper))
                                {
                                    if (mapper != client)
                                    {
                                        // We're on the same map...
                                        if (mapper.Player.InMapEditor)
                                        {
                                            // We have the map editor open...
                                            Messenger.SendLiveMapEditorFillLayerData(mapper, layer, set, tile);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "mapeditorfillattribute":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                if (client.Player.Map.MapType == Enums.MapType.House)
                                {
                                    if (((House)client.Player.Map).OwnerID != client.Player.CharID)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            if (client.Player.Map.MapType != Enums.MapType.Standard && client.Player.Map.MapType != Enums.MapType.House)
                            {
                                Messenger.PlayerMsg(client, "You can't edit a non-standard map!", Text.BrightRed);
                                return;
                            }

                            int type = parse[1].ToInt();
                            int data1 = parse[2].ToInt();
                            int data2 = parse[3].ToInt();
                            int data3 = parse[4].ToInt();
                            string string1 = parse[5];
                            string string2 = parse[6];
                            string string3 = parse[7];
                            int dungeonValue = parse[8].ToInt();

                            IMap map = client.Player.Map;
                            foreach (Client mapper in map.GetClients())
                            {
                                // We only want to check the mappers
                                if (Ranks.IsAllowed(mapper, Enums.Rank.Mapper))
                                {
                                    if (mapper != client)
                                    {
                                        // We're on the same map...
                                        if (mapper.Player.InMapEditor)
                                        {
                                            // We have the map editor open...
                                            Messenger.SendLiveMapEditorFillAttributeData(mapper, type, data1, data2, data3,
                                                string1, string2, string3, dungeonValue);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    #endregion
                    #region Items
                    case "requestedititem":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                        {
                            Messenger.HackingAttempt(client, "Admin cloning");
                            return;
                        }
                        Messenger.SendItemEditor(client);
                        break;
                    //case "edititem": { ~unneeded due to the info already being clientside
                    //        int n = -1;
                    //        if (Ranks.IsDisallowed(client, Enums.Rank.Developer)) {
                    //            Messenger.HackingAttempt(client, "Admin cloning");
                    //            return;
                    //        }

                    //        n = parse[1].ToInt();

                    //        if (n < 0 || n > Items.ItemManager.Items.MaxItems) {
                    //            Messenger.HackingAttempt(client, "Invalid item client");
                    //            return;
                    //        }

                    // record in log here
                    //        Messenger.SendEditItemTo(client, n);
                    //    }
                    //    break;
                    case "saveitem":
                        {
                            int n = -1;
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            n = parse[1].ToInt();

                            if (n < 0 || n >= Items.ItemManager.Items.MaxItems)
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            ItemManager.Items[n].Name = parse[2];
                            ItemManager.Items[n].Desc = parse[3];
                            ItemManager.Items[n].Pic = parse[4].ToInt();
                            ItemManager.Items[n].Type = (Enums.ItemType)parse[5].ToInt();
                            ItemManager.Items[n].Data1 = parse[6].ToInt();
                            ItemManager.Items[n].Data2 = parse[7].ToInt();
                            ItemManager.Items[n].Data3 = parse[8].ToInt();
                            ItemManager.Items[n].Price = parse[9].ToInt();
                            ItemManager.Items[n].StackCap = parse[10].ToInt();
                            ItemManager.Items[n].Bound = parse[11].ToBool();
                            ItemManager.Items[n].Loseable = parse[12].ToBool();
                            ItemManager.Items[n].Rarity = parse[13].ToInt();
                            ItemManager.Items[n].ReqData1 = parse[14].ToInt();
                            ItemManager.Items[n].ReqData2 = parse[15].ToInt();
                            ItemManager.Items[n].ReqData3 = parse[16].ToInt();
                            ItemManager.Items[n].ReqData4 = parse[17].ToInt();
                            ItemManager.Items[n].ReqData5 = parse[18].ToInt();
                            ItemManager.Items[n].ScriptedReq = parse[19].ToInt();

                            ItemManager.Items[n].AddHP = parse[20].ToInt();
                            ItemManager.Items[n].AddPP = parse[21].ToInt();
                            ItemManager.Items[n].AddAttack = parse[22].ToInt();
                            ItemManager.Items[n].AddDefense = parse[23].ToInt();
                            ItemManager.Items[n].AddSpAtk = parse[24].ToInt();
                            ItemManager.Items[n].AddSpDef = parse[25].ToInt();
                            ItemManager.Items[n].AddSpeed = parse[26].ToInt();
                            ItemManager.Items[n].AddEXP = parse[27].ToInt();
                            ItemManager.Items[n].AttackSpeed = parse[28].ToInt();
                            ItemManager.Items[n].RecruitBonus = parse[29].ToInt();

                            Messenger.SendUpdateItemToAll(n);
                            ItemManager.SaveItem(n);
                        }
                        break;
                    #endregion
                    #region Stories
                    case "requesteditstory":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                        {
                            Messenger.HackingAttempt(client, "Admin cloning");
                            return;
                        }

                        Messenger.SendDataTo(client, TcpPacket.CreatePacket("storyeditor"));
                        break;
                    case "savestory":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            int n = parse[1].ToInt();

                            if (n < 0 || n > Stories.StoryManager.Stories.MaxStories)
                            {
                                Messenger.HackingAttempt(client, "Invalid story client");
                                return;
                            }
                            Story story = new Story(StoryManager.Stories[n].ID);
                            story.Name = parse[2];
                            story.StoryStart = parse[3].ToInt();
                            story.Revision = StoryManager.Stories[n].Revision + 1;

                            int totalSegments = parse[4].ToInt();
                            int z = 5;
                            for (int i = 0; i < totalSegments; i++)
                            {
                                story.Segments.Add(new StorySegment());
                                int totalParameters = parse[z].ToInt();
                                story.Segments[i].Action = (Enums.StoryAction)parse[z + 1].ToInt();
                                z += 2;
                                for (int a = 0; a < totalParameters; a++)
                                {
                                    story.Segments[i].AddParameter(parse[z], parse[z + 1]);
                                    z += 2;
                                }
                            }
                            int exitContinueCount = parse[z].ToInt();
                            z++;
                            for (int i = 0; i < exitContinueCount; i++)
                            {
                                story.ExitAndContinue.Add(parse[z].ToInt(1));
                                z++;
                            }
                            StoryManager.Stories.Stories[n] = story;
                            Messenger.SendUpdateStoryNameToAll(n);
                            StoryManager.SaveStory(n);
                        }
                        break;
                    case "editstory":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            int n = parse[1].ToInt();
                            if (n < 0 || n > Stories.StoryManager.Stories.MaxStories)
                            {
                                Messenger.HackingAttempt(client, "Invalid story client");
                                return;
                            }
                            Messenger.SendEditStoryTo(client, n);
                        }
                        break;
                    case "requeststory":
                        Messenger.SendUpdateStoryTo(client, parse[1].ToInt());
                        break;
                    #endregion
                    #region Evolutions
                    case "requesteditevo":
                        // Prevent hacking
                        if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }

                        Messenger.SendDataTo(client, TcpPacket.CreatePacket("evoeditor"));
                        break;
                    case "editevo":
                        {

                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            // The evo #
                            int n = parse[1].ToInt(-1);

                            // Prevent hacking
                            if (n < 0 || n > Evolutions.EvolutionManager.Evolutions.MaxEvos)
                            {
                                Messenger.HackingAttempt(client, "Invalid Evolution Index");
                                return;
                            }

                            Messenger.SendEditEvoTo(client, n);
                        }
                        break;
                    case "saveevo":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            int n = parse[1].ToInt(-1);

                            // Prevent hacking
                            if (n < 0 | n > Evolutions.EvolutionManager.Evolutions.MaxEvos)
                            {
                                Messenger.HackingAttempt(client, "Invalid Evolution Index");
                                return;
                            }
                            Evolution evo = new Evolution();

                            evo.Name = parse[2];
                            evo.Species = parse[3].ToInt();
                            int z = 5;
                            for (int i = 0; i < parse[4].ToInt(); i++)
                            {
                                evo.Branches.Add(new EvolutionBranch());
                                evo.Branches[i].Name = parse[z];
                                evo.Branches[i].NewSpecies = parse[z + 1].ToInt();
                                evo.Branches[i].ReqScript = parse[z + 2].ToInt();
                                evo.Branches[i].Data1 = parse[z + 3].ToInt();
                                evo.Branches[i].Data2 = parse[z + 4].ToInt();
                                evo.Branches[i].Data3 = parse[z + 5].ToInt();
                                z += 6;
                            }
                            EvolutionManager.Evolutions[n] = evo;

                            Messenger.SendUpdateEvoToAll(n);
                            Evolutions.EvolutionManager.SaveEvo(n);
                        }
                        break;
                    #endregion
                    #region NPCs
                    case "requesteditnpc":

                        // Prevent hacking
                        if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }

                        Messenger.SendDataTo(client, TcpPacket.CreatePacket("NPCEDITOR"));
                        break;
                    // :::::::::::::::::::::
                    // :: Edit npc packet ::
                    // :::::::::::::::::::::
                    case "editnpc":
                        {

                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            // The npc #
                            int n = parse[1].ToInt(-1);

                            // Prevent hacking
                            if (n < 0 | n > Npcs.NpcManager.Npcs.MaxNpcs)
                            {
                                Messenger.HackingAttempt(client, "Invalid NPC Index");
                                return;
                            }

                            Messenger.SendNpcAiTypes(client);
                            Messenger.SendEditNpcTo(client, n);
                        }
                        break;
                    case "addnewnpc":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            Messenger.SendAddNpcToAll(NpcManager.AddNpc());
                        }
                        break;
                    // :::::::::::::::::::::
                    // :: Save npc packet ::
                    // :::::::::::::::::::::
                    case "savenpc":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            int n = parse[1].ToInt(-1);

                            // Prevent hacking
                            if (n < 0 | n > Npcs.NpcManager.Npcs.MaxNpcs)
                            {
                                Messenger.HackingAttempt(client, "Invalid NPC Index");
                                return;
                            }

                            Npc npc = new Npc();

                            // Update the npc
                            npc.Name = parse[2];
                            npc.AttackSay = parse[3];
                            npc.Form = parse[4].ToInt();
                            npc.Species = parse[5].ToInt();
                            npc.ShinyChance = parse[6].ToInt();
                            npc.Behavior = (Enums.NpcBehavior)parse[7].ToInt();
                            npc.RecruitRate = parse[8].ToInt();
                            npc.AIScript = parse[9];
                            npc.SpawnsAtDawn = parse[10].ToBool();
                            npc.SpawnsAtDay = parse[11].ToBool();
                            npc.SpawnsAtDusk = parse[12].ToBool();
                            npc.SpawnsAtNight = parse[13].ToBool();

                            int z = 14;
                            // Load npc moves
                            for (int i = 0; i < npc.Moves.Length; i++)
                            {
                                npc.Moves[i] = parse[z].ToInt();

                                z += 1;
                            }
                            // Load npc drops
                            for (int i = 0; i < npc.Drops.Length; i++)
                            {
                                npc.Drops[i] = new NpcDrop();
                                npc.Drops[i].ItemNum = parse[z].ToInt();
                                npc.Drops[i].ItemValue = parse[z + 1].ToInt();
                                npc.Drops[i].Chance = parse[z + 2].ToInt();
                                npc.Drops[i].Tag = parse[z + 3];

                                z += 4;
                            }
                            NpcManager.Npcs[n] = npc;
                            // Save it
                            Messenger.SendUpdateNpcToAll(n);
                            NpcManager.SaveNpc(n);
                        }
                        break;
                    #endregion
                    #region Shops
                    case "requesteditshop":
                        // Prevent hacking
                        if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }

                        Messenger.SendDataTo(client, TcpPacket.CreatePacket("shopeditor"));
                        break;
                    // ::::::::::::::::::::::
                    // :: Edit shop packet ::
                    // ::::::::::::::::::::::
                    case "editshop":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            // The shop #
                            int n = parse[1].ToInt(-1);
                            // Prevent hacking
                            if (n < 0 || n > Shops.ShopManager.Shops.MaxShops)
                            {
                                Messenger.HackingAttempt(client, "Invalid Shop Index");
                                return;
                            }

                            Messenger.SendEditShopTo(client, n);
                        }
                        break;
                    // ::::::::::::::::::::::
                    // :: Save shop packet ::
                    // ::::::::::::::::::::::
                    case "saveshop":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            int ShopNum = parse[1].ToInt(-1);
                            // Prevent hacking
                            if (ShopNum < 0 || ShopNum > Shops.ShopManager.Shops.MaxShops)
                            {
                                Messenger.HackingAttempt(client, "Invalid Shop Index");
                                return;
                            }

                            Shop shop = new Shop();

                            // Update the shop
                            shop.Name = parse[2];
                            shop.JoinSay = parse[3];
                            shop.LeaveSay = parse[4];
                            //shop.FixesItems = parse[5].ToBool(); ;
                            int n = 5;

                            for (int i = 0; i < Constants.MAX_TRADES; i++)
                            {
                                shop.Items[i].GiveItem = parse[n].ToInt();
                                shop.Items[i].GiveValue = parse[n + 1].ToInt();
                                shop.Items[i].GetItem = parse[n + 2].ToInt();
                                //shop.Sections[z].Items[i].GetValue = parse[n + 3].ToInt();
                                n = n + 3;
                            }

                            ShopManager.Shops[ShopNum] = shop;
                            // Save it
                            Messenger.SendUpdateShopToAll(ShopNum);
                            ShopManager.SaveShop(ShopNum);
                        }
                        break;
                    #endregion
                    #region Moves
                    case "requesteditmove":
                        // Prevent hacking
                        if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }

                        Messenger.SendDataTo(client, TcpPacket.CreatePacket("moveeditor"));
                        break;
                    // :::::::::::::::::::::::
                    // :: Edit move packet ::
                    // :::::::::::::::::::::::
                    case "editmove":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            // The spell #
                            int n = parse[1].ToInt(-1);

                            // Prevent hacking
                            if (n < 0 | n > Moves.MoveManager.Moves.MaxMoves)
                            {
                                Messenger.HackingAttempt(client, "Invalid Move Index");
                                return;
                            }

                            Messenger.SendEditMoveTo(client, n);
                        }
                        break;
                    // :::::::::::::::::::::::
                    // :: Save move packet ::
                    // :::::::::::::::::::::::
                    case "savemove":
                        { //
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            // Move #
                            int n = parse[1].ToInt(-1);

                            // Prevent hacking
                            if (n < 0 | n > Moves.MoveManager.Moves.MaxMoves)
                            {
                                Messenger.HackingAttempt(client, "Invalid Move Index");
                                return;
                            }

                            Move move = new Move();

                            // Update the spell
                            move.Name = parse[2];
                            move.MaxPP = parse[3].ToInt();
                            move.EffectType = (Enums.MoveType)parse[4].ToInt();
                            move.Element = (Enums.PokemonType)parse[5].ToInt();
                            move.MoveCategory = (Enums.MoveCategory)parse[6].ToInt();
                            move.TargetType = (Enums.MoveTarget)parse[7].ToInt();
                            move.RangeType = (Enums.MoveRange)parse[8].ToInt();
                            move.Range = parse[9].ToInt();

                            move.Data1 = parse[10].ToInt();
                            move.Data2 = parse[11].ToInt();
                            move.Data3 = parse[12].ToInt();

                            move.Accuracy = parse[13].ToInt();

                            move.HitTime = parse[14].ToInt();
                            move.HitFreeze = parse[15].ToBool();

                            move.AdditionalEffectData1 = parse[16].ToInt();
                            move.AdditionalEffectData2 = parse[17].ToInt();
                            move.AdditionalEffectData3 = parse[18].ToInt();
                            move.PerPlayer = parse[19].ToBool();
                            move.KeyItem = parse[20].ToInt();

                            move.Sound = parse[21].ToInt();

                            move.AttackerAnim.AnimationType = (Enums.MoveAnimationType)parse[22].ToInt();
                            move.AttackerAnim.AnimationIndex = parse[23].ToInt();
                            move.AttackerAnim.FrameSpeed = parse[24].ToInt();
                            move.AttackerAnim.Repetitions = parse[25].ToInt();

                            move.TravelingAnim.AnimationType = (Enums.MoveAnimationType)parse[26].ToInt();
                            move.TravelingAnim.AnimationIndex = parse[27].ToInt();
                            move.TravelingAnim.FrameSpeed = parse[28].ToInt();
                            move.TravelingAnim.Repetitions = parse[29].ToInt();

                            move.DefenderAnim.AnimationType = (Enums.MoveAnimationType)parse[30].ToInt();
                            move.DefenderAnim.AnimationIndex = parse[31].ToInt();
                            move.DefenderAnim.FrameSpeed = parse[32].ToInt();
                            move.DefenderAnim.Repetitions = parse[33].ToInt();

                            MoveManager.Moves[n] = move;

                            // Save it
                            Messenger.SendUpdateMoveToAll(n);
                            MoveManager.SaveMove(n);
                        }
                        break;
                    #endregion
                    #region Arrows
                    case "requesteditarrow":
                        // Prevent hacking
                        if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        Messenger.SendArrowEditor(client);
                        break;
                    case "editarrow":
                        {
                            // Prevent hacking
                            //if (Ranks.IsDisallowed(client, Enums.Rank.Developer)) {
                            //    Messenger.HackingAttempt(client, "Admin Cloning");
                            //    return;
                            //}
                            //int n = parse[1].ToInt(-1);
                            //if (n < 0 | n > Constants.MAX_ARROWS) {
                            //    Messenger.HackingAttempt(client, "Invalid arrow Index");
                            //    return;
                            //}
                            //Messenger.SendEditArrowTo(client, n);
                        }
                        break;
                    case "savearrow":
                        {
                            // Prevent hacking
                            //if (Ranks.IsDisallowed(client, Enums.Rank.Developer)) {
                            //    Messenger.HackingAttempt(client, "Admin Cloning");
                            //    return;
                            //}
                            //int n = parse[1].ToInt(-1);
                            //if (n < 0 | n > Constants.MAX_ARROWS) {
                            //    Messenger.HackingAttempt(client, "Invalid arrow Index");
                            //    return;
                            //}
                            //ArrowManagerBase.Arrows[n].Name = parse[2];
                            //ArrowManagerBase.Arrows[n].Pic = parse[3].ToInt();
                            //ArrowManagerBase.Arrows[n].Range = parse[4].ToInt();
                            //ArrowManagerBase.Arrows[n].Amount = parse[5].ToInt();
                            //Messenger.SendUpdateArrowToAll(n);
                            //ArrowManagerBase.SaveArrows();
                        }
                        break;
                    #endregion
                    #region Scripts
                    case "requesteditscript":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                Messenger.AdminMsg("All Admins: " + client.Player.Name + " has attempted to access the script editor", Text.BrightRed);
                            }
                            else
                            {
                                Scripting.Editor.EditorHelper.InitTempScript(client);
                                if (parse[1].ToBool() == false)
                                {
                                    Messenger.SendDataTo(client, TcpPacket.CreatePacket("scriptsyntax", System.IO.File.ReadAllText(IO.Paths.ScriptsFolder + "CSharp.syn")));
                                }
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("scripteditstart"));
                                Messenger.SendDataTo(client, TcpPacket.CreatePacket("scripteditdata", "Main.cs", System.IO.File.ReadAllText(IO.Paths.ScriptsFolder + "Main.cs").Replace(TcpPacket.SEP_CHAR, '/')));
                                Scripting.Editor.EditorHelper.SendScriptClasses(client);
                                TcpPacket filelistPacket = new TcpPacket("scriptfilelist");
                                Scripting.Editor.EditorHelper.AppendFileListToPacket(client, filelistPacket);
                                filelistPacket.FinalizePacket();
                                Messenger.SendDataTo(client, filelistPacket);
                                client.Player.InScriptEditor = true;
                            }
                        }
                        break;
                    case "savescript":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            System.IO.File.WriteAllText(Scripting.Editor.EditorHelper.GetTempFolder(client) + parse[1] + ".cs", parse[2]);
                            Messenger.PlayerMsg(client, "File Saved! (Temp)", Text.Yellow);
                        }
                        break;
                    case "finalizescript":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            bool testVal = Scripting.ScriptManager.TestCompile(Scripting.Editor.EditorHelper.GetTempFolder(client));
                            if (testVal)
                            {
                                Scripting.Editor.EditorHelper.SaveScript(client);
                                Messenger.PlayerMsg(client, "Script Compiled and Saved!", Text.Yellow);
                                Scripting.Editor.EditorHelper.SendScriptErrors(client);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "Error during script compilation... Script was not saved.", Text.Yellow);
                                Scripting.Editor.EditorHelper.SendScriptErrors(client);
                            }
                        }
                        break;
                    case "savetemp":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning.");
                            return;
                        }
                        else
                        {
                            Scripting.Editor.EditorHelper.SaveTempScript(client, parse[1], parse[2]);
                        }
                        break;
                    case "compilescript":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning.");
                            return;
                        }
                        else
                        {
                            bool testVal = Scripting.ScriptManager.TestCompile(Scripting.Editor.EditorHelper.GetTempFolder(client));
                            if (testVal)
                            {
                                Scripting.Editor.EditorHelper.SaveScript(client);
                                Messenger.PlayerMsg(client, "Script Compiled and Saved!", Text.Yellow);
                                Scripting.Editor.EditorHelper.SendScriptErrors(client);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "Error during script compilation... Script was not saved.", Text.Yellow);
                                Scripting.Editor.EditorHelper.SendScriptErrors(client);
                            }
                        }
                        break;
                    case "scripteditexit":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            return;
                        }
                        else
                        {
                            client.Player.InScriptEditor = false;
                            if (System.IO.Directory.Exists(Scripting.Editor.EditorHelper.GetTempFolder(client)))
                            {
                                System.IO.Directory.Delete(Scripting.Editor.EditorHelper.GetTempFolder(client), true);
                            }
                        }
                        break;
                    case "getscriptclasses":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            Scripting.Editor.EditorHelper.SendScriptClasses(client);
                        }
                        break;
                    case "getscriptmethods":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            Scripting.Editor.EditorHelper.SendScriptMethods(client, parse[1]);
                        }
                        break;
                    case "getscriptparam":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            Scripting.Editor.EditorHelper.SendScriptParameters(client, parse[1], parse[2], parse[3].ToInt(1));
                        }
                        break;
                    case "requestscriptsyntax":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            Messenger.SendDataTo(client, TcpPacket.CreatePacket("scriptsyntax", System.IO.File.ReadAllText(IO.Paths.ScriptsFolder + "CSharp.syn")));
                        }
                        break;
                    case "requesteditscriptfile":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            Messenger.SendDataTo(client, TcpPacket.CreatePacket("scriptfiledata", parse[1], Scripting.Editor.EditorHelper.GetScriptFile(client, parse[1])));
                        }
                        break;
                    case "requestfilelist":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            TcpPacket filelistPacket = new TcpPacket("scriptfilelist");
                            Scripting.Editor.EditorHelper.AppendFileListToPacket(client, filelistPacket);
                            filelistPacket.FinalizePacket();
                            Messenger.SendDataTo(client, filelistPacket);
                        }
                        break;
                    case "addnewclass":
                        if (Ranks.IsDisallowed(client, Enums.Rank.Scripter))
                        {
                            Messenger.HackingAttempt(client, "Admin Cloning");
                            return;
                        }
                        else
                        {
                            Scripting.Editor.EditorHelper.AddNewClass(client, parse[1]);
                            TcpPacket filelistPacket = new TcpPacket("scriptfilelist");
                            Scripting.Editor.EditorHelper.AppendFileListToPacket(client, filelistPacket);
                            filelistPacket.FinalizePacket();
                            Messenger.SendDataTo(client, filelistPacket);
                        }
                        break;

                    #endregion
                    #region Dungeons
                    case "requesteditdungeon":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            Messenger.SendDataTo(client, TcpPacket.CreatePacket("dungeoneditor"));
                        }
                        break;
                    case "addnewdungeon":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            DungeonManager.AddDungeon();
                            Messenger.SendAddDungeonToAll(DungeonManager.Dungeons.Count - 1);
                        }
                        break;
                    case "savedungeon":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            int n = parse[1].ToInt();

                            if (n < 0 || n > DungeonManager.Dungeons.Count)
                            {
                                return;
                            }

                            Dungeons.Dungeon dungeon = new Dungeon();

                            dungeon.Name = parse[2];
                            dungeon.AllowsRescue = parse[3].ToBool();

                            int scriptCount = parse[4].ToInt();

                            int z = 5;

                            for (int i = 0; i < scriptCount; i++)
                            {
                                dungeon.ScriptList.Add(parse[z].ToInt(), parse[z + 1]);
                                z += 2;
                            }

                            int standardMapCount = parse[z].ToInt();
                            z++;

                            for (int i = 0; i < standardMapCount; i++)
                            {
                                StandardDungeonMap map = new StandardDungeonMap();
                                map.Difficulty = (Enums.JobDifficulty)parse[z].ToInt();
                                map.IsBadGoalMap = parse[z + 1].ToBool();
                                map.MapNum = parse[z + 2].ToInt();
                                z += 3;
                                dungeon.StandardMaps.Add(map);
                            }

                            int randomMapCount = parse[z].ToInt();
                            z++;
                            for (int i = 0; i < randomMapCount; i++)
                            {
                                RandomDungeonMap map = new RandomDungeonMap();
                                map.Difficulty = (Enums.JobDifficulty)parse[z].ToInt();
                                map.IsBadGoalMap = parse[z + 1].ToBool();
                                map.RDungeonIndex = parse[z + 2].ToInt();
                                map.RDungeonFloor = parse[z + 3].ToInt();
                                z += 4;
                                dungeon.RandomMaps.Add(map);
                            }

                            DungeonManager.Dungeons[n] = dungeon;
                            DungeonManager.SaveDungeon(n);
                            Messenger.SendUpdateDungeonToAll(n);
                        }
                        break;
                    case "editdungeon":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            int n = parse[1].ToInt();

                            if (n < 0 || n > DungeonManager.Dungeons.Count)
                            {
                                Messenger.HackingAttempt(client, "Invalid dungeon client");
                                return;
                            }

                            Messenger.SendEditDungeonTo(client, n);
                        }
                        break;
                    #endregion
                    #region Missions
                    case "requesteditmission":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            Messenger.SendDataTo(client, TcpPacket.CreatePacket("missioneditor"));
                        }
                        break;
                    case "savemission":
                        {
                            WonderMails.MissionPool missionPool = new WonderMails.MissionPool();

                            int difficulty = parse[1].ToInt() - 1;

                            int clientCount = parse[2].ToInt();
                            int n = 3;
                            for (int i = 0; i < clientCount; i++)
                            {
                                WonderMails.MissionClientData missionClient = new WonderMails.MissionClientData();
                                missionClient.Species = parse[n].ToInt();
                                missionClient.Form = parse[n + 1].ToInt();
                                missionPool.MissionClients.Add(missionClient);

                                n += 2;

                            }

                            int enemyCount = parse[n].ToInt();
                            n++;

                            for (int i = 0; i < enemyCount; i++)
                            {
                                WonderMails.MissionEnemyData missionEnemy = new WonderMails.MissionEnemyData();
                                missionEnemy.NpcNum = parse[n].ToInt();
                                missionPool.Enemies.Add(missionEnemy);

                                n++;
                            }

                            int rewardCount = parse[n].ToInt();
                            n++;

                            for (int i = 0; i < rewardCount; i++)
                            {

                                WonderMails.MissionRewardData missionReward = new WonderMails.MissionRewardData(); ;
                                missionReward.ItemNum = parse[n].ToInt();
                                missionReward.Amount = parse[n + 1].ToInt();
                                missionReward.Tag = parse[n + 2];
                                missionPool.Rewards.Add(missionReward);

                                n += 3;

                            }

                            WonderMails.WonderMailManager.Missions[difficulty] = missionPool;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data))
                            {
                                WonderMails.WonderMailManager.SaveMissionPool(dbConnection, difficulty);
                            }
                        }
                        break;
                    case "editmission":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Developer))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }

                            int n = parse[1].ToInt();

                            if (n < 0 || n > 16)
                            {
                                Messenger.HackingAttempt(client, "Invalid mission client");
                                return;
                            }

                            Messenger.SendEditMissionTo(client, n - 1);
                        }
                        break;
                    #endregion

                    #endregion
                    #region Online List
                    case "whosonline":
                        Messenger.SendWhosOnline(client);
                        break;
                    case "onlinelist":
                        Messenger.SendOnlineList(client);
                        break;
                    case "playerinforequest":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Moniter))
                            {
                                string name = parse[1];
                                Client i = ClientManager.FindClient(name);
                                if (i != null)
                                {
                                    Messenger.PlayerMsg(client, "Account: " + i.Player.AccountName.Trim() + ", " + i.Player.Name.Trim(), Text.BrightGreen);
                                    Messenger.PlayerMsg(client, "-=- Stats for " + i.Player.Name + " -=-", Text.BrightGreen);
                                    Messenger.PlayerMsg(client, "Level: " + i.Player.GetActiveRecruit().Level.ToString() + " Exp: " + i.Player.GetActiveRecruit().Exp.ToString() + "/" + i.Player.GetActiveRecruit().GetNextLevel().ToString(), Text.BrightGreen);
                                    Messenger.PlayerMsg(client, "HP: " + i.Player.GetActiveRecruit().HP.ToString() + "/" + i.Player.GetMaxHP().ToString(), Text.BrightGreen);
                                    Messenger.PlayerMsg(client, "Atk: " + i.Player.GetActiveRecruit().Atk.ToString() + "  Def: " + i.Player.GetActiveRecruit().Def.ToString() + "  Sp.Atk: " + i.Player.GetActiveRecruit().SpclAtk.ToString() + "  Sp.Def: " + i.Player.GetActiveRecruit().SpclDef.ToString() + "  Speed: " + i.Player.GetActiveRecruit().Spd.ToString(), Text.BrightGreen);
                                    Messenger.PlayerMsg(client, "Species: " + i.Player.GetActiveRecruit().Species.ToString() + " [" + Pokedex.Pokedex.GetPokemon(i.Player.GetActiveRecruit().Species).Name + "]    Sprite: " + i.Player.GetActiveRecruit().Sprite.ToString(), Text.BrightGreen);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                            }
                        }
                        break;
                    case "getstats":
                        {
                            Messenger.PlayerMsg(client, "-=- Stats for " + client.Player.Name + " -=-", Text.BrightGreen);
                            Messenger.PlayerMsg(client, "Level: " + client.Player.GetActiveRecruit().Level.ToString() + " Exp: " + client.Player.GetActiveRecruit().Exp.ToString() + "/" + client.Player.GetActiveRecruit().GetNextLevel().ToString(), Text.BrightGreen);
                            Messenger.PlayerMsg(client, "HP: " + client.Player.GetActiveRecruit().HP.ToString() + "/" + client.Player.GetMaxHP().ToString(), Text.BrightGreen);
                            Messenger.PlayerMsg(client, "Atk: " + client.Player.GetActiveRecruit().Atk.ToString() + "  Def: " + client.Player.GetActiveRecruit().Def.ToString() + "  Sp.Str: " + client.Player.GetActiveRecruit().SpclAtk.ToString() + "  Sp.Def: " + client.Player.GetActiveRecruit().SpclDef.ToString() + "  Speed: " + client.Player.GetActiveRecruit().Spd.ToString(), Text.BrightGreen);
                            Messenger.PlayerMsg(client, "Species: " + Pokedex.Pokedex.GetPokemon(client.Player.GetActiveRecruit().Species).Name, Text.BrightGreen);
                        }
                        break;
                    #endregion
                    #region Admin Commands
                    case "setaccess":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Admin))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            // The client
                            Client n = ClientManager.FindClient(parse[1]);
                            // The access
                            int i = parse[2].ToInt(-1);

                            // Check for invalid access level
                            if (i >= 0 || i <= 3)
                            {
                                if (client.Player.Name != n.Player.Name)
                                {
                                    // Check if player is on
                                    if (n != null)
                                    {
                                        if (Ranks.IsAllowed(client, (Enums.Rank)i))
                                        {
                                            if (Ranks.IsDisallowed(n, Enums.Rank.Moniter))
                                            {
                                                Messenger.GlobalMsg(n.Player.Name + " has been blessed with administrative access.", Text.BrightBlue);
                                            }

                                            n.Player.Access = (Enums.Rank)i;
                                            Messenger.SendPlayerData(n);

                                            if (Ranks.IsAllowed(n, Enums.Rank.Mapper))
                                            {
                                                n.Player.AddExpKitModule(new AvailableExpKitModule(Enums.ExpKitModules.MapReport, true));
                                            }
                                            else
                                            {
                                                if (n.Player.AvailableExpKitModules.Contains(Enums.ExpKitModules.MapReport))
                                                {
                                                    n.Player.RemoveExpKitModule(Enums.ExpKitModules.MapReport);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Messenger.PlayerMsg(client, "You cannot set someone's access higher than yours!", Text.BrightRed);
                                        }
                                    }
                                    else
                                    {
                                        Messenger.PlayerMsg(client, "Player is not online.", Text.White);
                                    }
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "You cant change your access.", Text.Red);
                                }
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "Invalid access level.", Text.Red);
                            }

                        }
                        break;
                    case "setmotd":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            Settings.MOTD = parse[1];
                            Messenger.GlobalMsg("MOTD changed to: " + parse[1], Text.BrightCyan);
                            Settings.SaveMOTD();
                        }
                        break;
                    case "restartserver":
                        {
                            // Prevent hacking
                            if (Ranks.IsDisallowed(client, Enums.Rank.ServerHost))
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning");
                                return;
                            }

                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                foreach (Client i in ClientManager.GetClients())
                                {
                                    if (i.IsPlaying())
                                    {
                                        i.Player.SaveCharacterData(dbConnection);
                                    }
                                }
                            }
                            PlayerManager.SavingEnabled = false;

                            System.Windows.Forms.Application.Restart();
                            System.Environment.Exit(0);
                        }
                        break;
                    case "setsprite":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            else
                            {
                                int n = parse[1].ToInt(-1);
                                if (n > -1)
                                {
                                    client.Player.GetActiveRecruit().SetSpecies(n);
                                    Messenger.SendPlayerData(client);
                                    Messenger.SendActiveTeam(client);
                                    Messenger.SendStats(client);
                                }
                            }
                        }
                        break;
                    case "setplayersprite":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Admin))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            else
                            {
                                int n = parse[2].ToInt(-1);
                                Client player = ClientManager.FindClient(parse[1]);
                                if (n > -1 && player != null)
                                {
                                    player.Player.GetActiveRecruit().SetSpecies(n);
                                    Messenger.SendPlayerData(player);
                                    Messenger.SendActiveTeam(player);
                                    Messenger.SendStats(player);
                                }
                            }
                        }
                        break;
                    case "maprespawn":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            else
                            {
                                IMap map = client.Player.GetCurrentMap();
                                for (int i = 0; i < Constants.MAX_MAP_ITEMS; i++)
                                {
                                    map.SpawnItemSlot(i, -1, 0, false, false, "", map.ActiveItem[i].X, map.ActiveItem[i].Y, null);
                                    map.ClearActiveItem(i);
                                }
                                map.SpawnItems();

                                // Respawn NPCs
                                for (int i = 0; i < Constants.MAX_MAP_NPCS; i++)
                                {
                                    map.ClearActiveNpc(i);
                                }
                                map.SpawnNpcs();
                                Messenger.PlayerMsg(client, "Map respawned.", Text.Blue);
                            }
                        }
                        break;
                    case "kickplayer":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            else
                            {
                                Client n = ClientManager.FindClient(parse[1]);
                                if (n == client)
                                {
                                    Messenger.PlayerMsg(client, "You can't kick yourself!", Text.BrightRed);
                                }
                                else if (n == null)
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                                else if (Ranks.IsAllowed(n, client.Player.Access))
                                {
                                    Messenger.PlayerMsg(client, "That is a higher access admin than you!", Text.BrightRed);
                                }
                                else
                                {
                                    //Messenger.GlobalMsg(n.Player.Name + " has been kicked from " + Settings.GameName + " by " + client.Player.Name + "!", Text.White);
                                    //Messenger.AlertMsg(n, "You have been kicked by " + client.Player.Name + "!");
                                    Messenger.PlayerMsg(client, n.Player.Name + " has been kicked from the server!", Text.BrightGreen);
                                    Messenger.PlainMsg(n, "You have been kicked from the server!", Enums.PlainMsgType.MainMenu);
                                    n.CloseConnection();
                                }
                            }
                        }
                        break;
                    case "banplayer":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            else
                            {
                                Client n = ClientManager.FindClient(parse[1]);
                                if (n == client)
                                {
                                    Messenger.PlayerMsg(client, "You can't kick yourself!", Text.BrightRed);
                                }
                                else if (n == null)
                                {
                                    Messenger.PlayerMsg(client, "Player is offline.", Text.Grey);
                                }
                                else if (Ranks.IsAllowed(n, client.Player.Access))
                                {
                                    Messenger.PlayerMsg(client, "That is a higher access admin than you!", Text.BrightRed);
                                }
                                else
                                {
                                    //  Add banning to scripts
                                    //Messenger.GlobalMsg(n.Player.Name + " has been banned from " + Settings.GameName + " by " + client.Player.Name + "!", Text.White);
                                    //PlayerManager.AddToBanList(((System.Net.IPEndPoint)n.TcpClient.Socket.RemoteEndPoint).Address.ToString(), client.Player.Name, n.Player.Name);
                                    //Messenger.AlertMsg(n, "You have been kicked by " + client.Player.Name + "!");
                                }
                            }
                        }
                        break;
                    case "banlist":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Moniter))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            else
                            {
                                // TODO: Display ban list
                                //if (PlayerManager.Bans.Count > 0) {
                                //    string list = "";
                                //    for (int i = 0; i < PlayerManager.Bans.Count; i++) {
                                //        list += i.ToString() + ". IP: " + PlayerManager.Bans[i].BannedIP + ", Banned By: " + PlayerManager.Bans[i].BannedBy + ", Banned Player: " + PlayerManager.Bans[i].BannedAccount + "\r\n";
                                //    }
                                //    Messenger.PlayerMsg(client, list, Text.BrightBlue);
                                //} else {
                                //    Messenger.PlayerMsg(client, "There are no bans.", Text.BrightBlue);
                                //}
                            }
                        }
                        break;
                    // TODO: Unban all players/unban single player [MEDIUM]
                    case "banlistdestroy":
                        {

                        }
                        break;
                    case "warpto":
                        {
                            if (Ranks.IsDisallowed(client, Enums.Rank.Mapper))
                            {
                                Messenger.HackingAttempt(client, "Admin cloning");
                                return;
                            }
                            else
                            {
                                Messenger.PlayerWarp(client, parse[1].ToInt(), client.Player.X, client.Player.Y);
                            }
                        }
                        break;
                    case "warptome":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                Client n = ClientManager.FindClient(parse[1]);
                                if (n != null)
                                {
                                    Messenger.PlayerWarp(n, client.Player.Map, client.Player.X, client.Player.Y);
                                }
                            }
                        }
                        break;

                    case "warpmeto":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper))
                            {
                                Client n = ClientManager.FindClient(parse[1]);
                                if (n != null)
                                {
                                    Messenger.PlayerWarp(client, n.Player.Map, n.Player.X, n.Player.Y);
                                }
                            }
                        }
                        break;
                    case "warploc":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Mapper) || client.Player.Map.MapType == Enums.MapType.House && ((House)client.Player.Map).OwnerID == client.Player.CharID)
                            {
                                Messenger.PlayerXYWarp(client, parse[1].ToInt(), parse[2].ToInt());
                            }
                        }
                        break;
                    case "arrowhit":
                        {
                            // TODO: Easy way to damage any player. Modify arrow code to be processed server-side [HIGH]
                            int n = parse[1].ToInt();
                            int z = parse[2].ToInt();
                            int x = parse[3].ToInt();
                            int y = parse[4].ToInt();

                            // BattleProcessor.ArrowHit(client, (Enums.TargetType)n, z);
                        }
                        break;
                    case "saveplayer":
                        {
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                client.Player.SaveCharacterData(dbConnection);
                            }
                            Messenger.PlayerMsg(client, "You have saved the game.", Text.Yellow);
                        }
                        break;
                    case "solid":
                        {
                            if (client.Player.Solid == true)
                            {
                                client.Player.Solid = false;
                                Messenger.PlayerMsg(client, "You can run through players now.", Text.Yellow);
                            }
                            else
                            {
                                client.Player.Solid = true;
                                Messenger.PlayerMsg(client, "You can no longer run through players.", Text.Yellow);
                            }
                            Messenger.SendPlayerData(client);
                        }
                        break;
                    case "weather":
                        {
                            if (Ranks.IsAllowed(client, Enums.Rank.Developer))
                            {
                                int weather = parse[1].ToInt(-1);
                                if (weather > -1 && weather < 13)
                                {
                                    Globals.ServerWeather = (Enums.Weather)weather;
                                    if (Globals.ServerWeather != Enums.Weather.Ambiguous)
                                    {
                                        IMap[] mapArray = MapManager.ToArray();
                                        for (int i = 0; i < mapArray.Length; i++)
                                        {
                                            mapArray[i].Weather = Globals.ServerWeather;
                                        }
                                    }
                                    Messenger.SendWeatherToAll();
                                }
                            }
                            else
                            {
                                Messenger.HackingAttempt(client, "Admin Cloning [Changing Weather]");
                            }
                        }
                        break;
                    #endregion
                    #region Friends List
                    case "sendfriendslist":
                        client.Player.SendFriendsList();
                        break;
                    case "addfriend":
                        client.Player.AddFriend(parse[1]);
                        break;
                    case "removefriend":
                        client.Player.RemoveFriend(parse[1]);
                        break;
                    #endregion
                    #region Guild
                    case "guildpromote":
                        {

                            if (client.Player.GuildAccess < Enums.GuildRank.Founder)
                            {
                                Messenger.PlayerMsg(client, "You are not the owner of this guild!", Text.BrightRed);
                                return;
                            }

                            ListPair<string, int> members;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                members = DataManager.Players.PlayerDataManager.LoadGuild(dbConnection.Database, client.Player.GuildName);

                                if (parse[1].ToInt() > members.Count)
                                {
                                    Messenger.PlayerMsg(client, "That player doesn't seem to be in the guild anymore.", Text.BrightRed);
                                    return;
                                }

                                int adminCount = 0;
                                for (int i = 0; i < members.Count; i++)
                                {
                                    if (members.ValueByIndex(i) > 1)
                                    {
                                        adminCount++;
                                    }
                                }

                                if (client.Player.HasItem(1) < Guilds.GuildManager.PROMOTE_PRICE * adminCount)
                                {
                                    Messenger.PlayerMsg(client, "You need " + Guilds.GuildManager.PROMOTE_PRICE * adminCount + " " + ItemManager.Items[1].Name + " to promote a member.", Text.BrightRed);
                                    return;
                                }

                                client.Player.TakeItem(1, Guilds.GuildManager.PROMOTE_PRICE * adminCount, true);
                                DataManager.Players.PlayerDataManager.SetGuildAccess(dbConnection.Database, members.KeyByIndex(parse[1].ToInt()), (int)Enums.GuildRank.Admin);
                                Messenger.PlayerMsg(client, "The player has been promoted.", Text.Blue);

                            }

                            Client target = ClientManager.FindClientFromCharID(members.KeyByIndex(parse[1].ToInt()));

                            if (target != null)
                            {
                                //Set the player's New access level
                                target.Player.GuildAccess = Enums.GuildRank.Admin;
                                //send the guild access data to all
                                Messenger.SendPlayerGuild(target);
                            }
                            //send the update to all possible guild members
                            Messenger.SendFullGuildUpdate(client.Player.GuildName);
                        }
                        break;
                    case "guilddemote":
                        {

                            if (client.Player.GuildAccess < Enums.GuildRank.Founder)
                            {
                                Messenger.PlayerMsg(client, "You are not the owner of this guild!", Text.BrightRed);
                                return;
                            }
                            ListPair<string, int> members;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                members = DataManager.Players.PlayerDataManager.LoadGuild(dbConnection.Database, client.Player.GuildName);

                                if (parse[1].ToInt() > members.Count)
                                {
                                    Messenger.PlayerMsg(client, "That player doesn't seem to be in the guild anymore.", Text.BrightRed);
                                    return;
                                }

                                DataManager.Players.PlayerDataManager.SetGuildAccess(dbConnection.Database, members.KeyByIndex(parse[1].ToInt()), (int)Enums.GuildRank.Member);
                                Messenger.PlayerMsg(client, "The player has been demoted.", Text.Blue);
                            }

                            Client target = ClientManager.FindClientFromCharID(members.KeyByIndex(parse[1].ToInt()));

                            if (target != null)
                            {
                                //Set the player's New access level
                                target.Player.GuildAccess = Enums.GuildRank.Member;
                                //send the guild access data to all
                                Messenger.SendPlayerGuild(target);
                            }
                            //send the update to all possible guild members
                            Messenger.SendFullGuildUpdate(client.Player.GuildName);
                        }
                        break;
                    // Disown
                    case "guilddisown":
                        {

                            if (client.Player.GuildAccess < Enums.GuildRank.Admin)
                            {
                                Messenger.PlayerMsg(client, "Your guild rank isn't high enough to disown players!", Text.BrightRed);
                                return;
                            }
                            ListPair<string, int> members;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                members = DataManager.Players.PlayerDataManager.LoadGuild(dbConnection.Database, client.Player.GuildName);

                                if (parse[1].ToInt() > members.Count)
                                {
                                    Messenger.PlayerMsg(client, "That player doesn't seem to be in the guild anymore.", Text.BrightRed);
                                    return;
                                }

                                DataManager.Players.PlayerDataManager.RemoveGuildMember(dbConnection.Database, members.KeyByIndex(parse[1].ToInt()));
                                Messenger.PlayerMsg(client, "The player has been disowned.", Text.Blue);
                            }

                            Client target = ClientManager.FindClientFromCharID(members.KeyByIndex(parse[1].ToInt()));

                            if (target != null)
                            {
                                target.Player.GuildName = "";
                                target.Player.GuildAccess = Enums.GuildRank.None;
                                //send the guild access data to all
                                Messenger.SendPlayerGuild(target);
                            }
                            //send the update to all possible guild members
                            Messenger.SendFullGuildUpdate(client.Player.GuildName);
                        }
                        break;
                    // Leave Guild
                    case "guildleave":
                        {
                            // Check if they can leave
                            if (string.IsNullOrEmpty(client.Player.GuildName))
                            {
                                Messenger.PlayerMsg(client, "You are not in a guild.", Text.BrightRed);
                                return;
                            }
                            bool stepDown = false;
                            if (client.Player.GuildAccess > Enums.GuildRank.Member)
                            {
                                stepDown = true;
                            }

                            int index = -1;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                ListPair<string, int> members = DataManager.Players.PlayerDataManager.LoadGuild(dbConnection.Database, client.Player.GuildName);

                                index = members.IndexOfKey(client.Player.CharID);

                                int founders = 0;
                                for (int i = 0; i < members.Count; i++)
                                {
                                    if (members.ValueByIndex(i) == (int)Enums.GuildRank.Founder) founders++;
                                }

                                if (founders == 1 && client.Player.GuildAccess == Enums.GuildRank.Founder)
                                {
                                    Messenger.AskQuestion(client, "DisbandGuild", "As the sole founder of this guild, if you step down, the guild will be disbanded.  Is that OK?", -1);
                                }
                                else if (stepDown)
                                {
                                    Messenger.AskQuestion(client, "GuildStepDown", "Are you sure you want to step down from your current guild position?", -1);
                                }
                                else
                                {
                                    Messenger.AskQuestion(client, "GuildStepDown", "Are you sure you want to leave the guild?", -1);
                                }
                            }
                        }
                        break;
                    // Make A New Guild
                    case "makeguild":
                        {
                            string name = parse[1].Trim();

                            Guilds.GuildManager.RegisterGuild(client, name);

                        }
                        break;
                    case "guildmember":
                        {

                            if (client.Player.GuildAccess < Enums.GuildRank.Admin)
                            {
                                Messenger.PlayerMsg(client, "Your guild rank isn't high enough to add players!", Text.BrightRed);
                                return;
                            }

                            //find character ID from name in database
                            string charID;
                            string guild;
                            Client target = null;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                charID = DataManager.Players.PlayerDataManager.RetrieveCharacterID(dbConnection.Database, parse[1]);

                                if (String.IsNullOrEmpty(charID))
                                {
                                    Messenger.PlayerMsg(client, "The player could not be found.", Text.BrightRed);
                                    return;
                                }

                                target = ClientManager.FindClientFromCharID(charID);

                                if (target == null)
                                {
                                    Messenger.PlayerMsg(client, "That player isn't online!", Text.BrightRed);
                                    return;
                                }

                                if (target.Player.MapID != client.Player.MapID || target.Player.X != client.Player.X || target.Player.Y != client.Player.Y)
                                {
                                    Messenger.PlayerMsg(client, "The joining player needs to be with you on the same tile!", Text.BrightRed);
                                    return;
                                }

                                guild = DataManager.Players.PlayerDataManager.GetGuildName(dbConnection.Database, charID);

                                if (!String.IsNullOrEmpty(guild))
                                {
                                    Messenger.PlayerMsg(client, "That player is already in a guild!", Text.BrightRed);
                                    return;
                                }

                                ListPair<string, int> members = DataManager.Players.PlayerDataManager.LoadGuild(dbConnection.Database, client.Player.GuildName);

                                if (client.Player.HasItem(1) < Guilds.GuildManager.RECRUIT_PRICE * members.Count)
                                {
                                    Messenger.PlayerMsg(client, "You need " + Guilds.GuildManager.RECRUIT_PRICE * members.Count + " " + ItemManager.Items[1].Name + " to add a member.", Text.BrightRed);
                                    return;
                                }

                                client.Player.TakeItem(1, Guilds.GuildManager.RECRUIT_PRICE * members.Count, true);
                                DataManager.Players.PlayerDataManager.AddGuildMember(dbConnection.Database, client.Player.GuildName, charID);
                                Messenger.PlayerMsg(client, "The player has been added to the guild!", Text.Blue);
                            }

                            if (target != null)
                            {
                                target.Player.GuildName = client.Player.GuildName;
                                target.Player.GuildAccess = Enums.GuildRank.Member;
                                //send the guild access data to all
                                Messenger.SendPlayerGuild(target);
                            }
                            //send the update to all possible guild members
                            Messenger.SendFullGuildUpdate(client.Player.GuildName);
                        }
                        break;
                    #endregion
                    #region Items
                    case "useitem":
                        {
                            if (client.Player.GettingMap) return;
                            int invNum = parse[1].ToInt(-1);
                            if (invNum != -1 && (invNum < 1 || invNum > client.Player.MaxInv))
                            {
                                Messenger.HackingAttempt(client, "Invalid InvNum");
                                return;
                            }

                            client.Player.UseItem(client.Player.Inventory[invNum], invNum);
                        }
                        break;
                    case "throwitem":
                        {
                            if (client.Player.GettingMap) return;
                            int invNum = parse[1].ToInt(-1);
                            if (invNum != -1 && (invNum < 1 || invNum > client.Player.MaxInv))
                            {
                                Messenger.HackingAttempt(client, "Invalid InvNum");
                                return;
                            }
                            client.Player.ThrowItem(client.Player.Inventory[parse[1].ToInt(-1)], parse[1].ToInt(-1));
                        }
                        break;
                    case "holditem":
                        {
                            client.Player.HoldItem(parse[1].ToInt(-1));
                        }
                        break;
                    case "removeitem":
                        {
                            client.Player.RemoveItem(parse[1].ToInt(-1));
                        }
                        break;
                    case "swapinvitems":
                        {
                            int oldInvSlot = parse[1].ToInt(-1);
                            int newInvSlot = parse[2].ToInt(-1);
                            if (oldInvSlot > 0 && oldInvSlot <= client.Player.MaxInv && newInvSlot > 0 && newInvSlot <= client.Player.MaxInv)
                            {
                                InventoryItem oldItem = client.Player.Inventory[oldInvSlot];
                                InventoryItem newItem = client.Player.Inventory[newInvSlot];

                                oldItem.Updated = true;
                                newItem.Updated = true;

                                client.Player.Inventory[oldInvSlot] = newItem;
                                client.Player.Inventory[newInvSlot] = oldItem;

                                int[] teamHeldItems = new int[client.Player.Team.Length];
                                bool heldItemsUpdated = false;
                                for (int i = 0; i < client.Player.Team.Length; i++)
                                {
                                    if (client.Player.Team[i].Loaded)
                                    {
                                        teamHeldItems[i] = client.Player.Team[i].HeldItemSlot;
                                    }
                                }
                                for (int i = 0; i < teamHeldItems.Length; i++)
                                {
                                    if (teamHeldItems[i] == oldInvSlot)
                                    {
                                        client.Player.Team[i].HeldItemSlot = newInvSlot;
                                        heldItemsUpdated = true;
                                    }
                                    else if (teamHeldItems[i] == newInvSlot)
                                    {
                                        client.Player.Team[i].HeldItemSlot = oldInvSlot;
                                        heldItemsUpdated = true;
                                    }
                                }

                                PacketHitList hitlist = null;
                                PacketHitList.MethodStart(ref hitlist);

                                Messenger.SendInventoryUpdate(client, oldInvSlot, hitlist);
                                Messenger.SendInventoryUpdate(client, newInvSlot, hitlist);
                                if (heldItemsUpdated)
                                {
                                    PacketBuilder.AppendWornEquipment(client, hitlist);
                                }

                                PacketHitList.MethodEnded(ref hitlist);
                            }
                        }
                        break;
                    #endregion
                    #region Shops
                    case "shoprequest":
                        {
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Shop)
                            {
                                if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1 > 0)
                                {
                                    Messenger.SendTrade(client, client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1);
                                }
                                else
                                {
                                    Messenger.PlayerMsg(client, "There is no shop here.", Text.BrightRed);
                                }
                            }
                        }
                        break;
                    case "shopleave":
                        {
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Shop && client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1 > 0)
                            {
                                int shopNum = client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1;
                                if (Shops.ShopManager.Shops[shopNum].LeaveSay.Trim() != "")
                                {
                                    Messenger.PlayerMsg(client, Shops.ShopManager.Shops[shopNum].LeaveSay.Trim(), Text.Yellow);
                                }
                            }
                        }
                        break;
                    case "traderequest":
                        {
                            // Trade num
                            int n = parse[1].ToInt();
                            int z = parse[2].ToInt();

                            // Prevent hacking
                            if ((z < 0) || (z > Constants.MAX_TRADES))
                            {
                                Messenger.HackingAttempt(client, "Trade Request Modification (index)");
                                return;
                            }
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type != Enums.TileType.Shop)
                            {
                                Messenger.HackingAttempt(client, "Trade Request Modification (tile)");
                                return;
                            }

                            // Index for shop
                            int i = client.Player.GetCurrentMap().Tile[client.Player.X, client.Player.Y].Data1;

                            // Check if inv full
                            if (i <= 0) return;
                            int X = client.Player.FindInvSlot(ShopManager.Shops[i].Items[z].GetItem, n);
                            if (X == -1)
                            {
                                Messenger.PlayerMsg(client, "Trade unsuccessful, inventory full.", Text.BrightRed);
                                return;
                            }
                            if (n == 0)
                            {
                                if (ItemManager.Items[ShopManager.Shops[i].Items[z].GetItem].StackCap > 0)
                                {
                                    Messenger.PlayerMsg(client, "You must buy more than 0!", Text.BrightRed);
                                    return;
                                }
                                else
                                {
                                    n = 1;
                                }

                            }

                            if (ItemManager.Items[ShopManager.Shops[i].Items[z].GetItem].Rarity > (int)client.Player.ExplorerRank + 1)
                            {
                                Messenger.PlayerMsg(client, "Your Explorer Rank is not high enough to receive this item!", Text.BrightRed);
                                return;
                            }

                            // Check if they have the item
                            if (client.Player.HasItem(ShopManager.Shops[i].Items[z].GiveItem) >= ShopManager.Shops[i].Items[z].GiveValue * n)
                            {
                                client.Player.TakeItem(ShopManager.Shops[i].Items[z].GiveItem, ShopManager.Shops[i].Items[z].GiveValue * n);
                                client.Player.GiveItem(ShopManager.Shops[i].Items[z].GetItem, n);
                                Messenger.PlayerMsg(client, "The trade was successful!", Text.Yellow);
                                Messenger.SendInventory(client);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "Trade unsuccessful.", Text.BrightRed);
                            }
                        }
                        break;
                    case "sellitem":
                        {//sell multiples
                            int sellItemNum = parse[2].ToInt();
                            int SellItemAmount = parse[1].ToInt();

                            // Prevent hacking
                            if ((sellItemNum < 0) || (sellItemNum >= ItemManager.Items.MaxItems))
                            {
                                Messenger.HackingAttempt(client, "Trade Request Modification");
                                return;
                            }
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type != Enums.TileType.Shop)
                            {
                                Messenger.HackingAttempt(client, "Trade Request Modification");
                                return;
                            }
                            if (ItemManager.Items[sellItemNum].Price <= 0)
                            {
                                Messenger.PlayerMsg(client, "You can't sell that!", Text.BrightRed);
                                break;
                            }

                            if (SellItemAmount <= 0)
                            {
                                if (ItemManager.Items[sellItemNum].StackCap > 0)
                                {
                                    Messenger.PlayerMsg(client, "You must sell more than 0!", Text.BrightRed);
                                    break;
                                }
                                else
                                {
                                    SellItemAmount = 1;
                                }
                            }
                            if (client.Player.HasItem(sellItemNum) > 0)
                            {
                                if (client.Player.HasItem(sellItemNum) < SellItemAmount)
                                {
                                    Messenger.PlayerMsg(client, "You can't sell more than you have!", Text.BrightRed);
                                    break;
                                }
                                client.Player.TakeItem(sellItemNum, SellItemAmount);
                                client.Player.GiveItem(1, ItemManager.Items[sellItemNum].Price * SellItemAmount);
                                Messenger.SendInventory(client);
                                Messenger.PlayerMsg(client, "You have sold " + SellItemAmount + " " + Items.ItemManager.Items[sellItemNum].Name + "!", Text.BrightGreen);
                                //Messenger.SendDataTo(client, TcpPacket.CreatePacket("updatesell"));
                            }
                        }
                        break;
                    case "moverecall":
                        {
                            int recallMove = parse[1].ToInt();
                            // Prevent hacking
                            if ((recallMove <= 0) || (recallMove > MoveManager.Moves.MaxMoves))
                            {
                                Messenger.HackingAttempt(client, "Move Recall Out of Range :" + recallMove);
                                return;
                            }
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type != Enums.TileType.LinkShop)
                            {
                                return;
                            }

                            int priceItem = client.Player.Map.Tile[client.Player.X, client.Player.Y].Data1;
                            int priceAmount = client.Player.Map.Tile[client.Player.X, client.Player.Y].Data2;
                            bool earlierEvo = (client.Player.Map.Tile[client.Player.X, client.Player.Y].Data3 == 1);
                            if (Items.ItemManager.Items[priceItem].StackCap <= 0 && Items.ItemManager.Items[priceItem].Type != Enums.ItemType.Currency)
                            {
                                priceAmount = 1;
                            }

                            for (int i = 0; i < 4; i++)
                            {
                                if (client.Player.GetActiveRecruit().Moves[i].MoveNum == recallMove)
                                {
                                    Messenger.PlayerMsg(client, "You already know this move.", Text.BrightRed);
                                    return;
                                }
                            }

                            if (earlierEvo)
                            {
                                int species = EvolutionManager.FindPreEvolution(client.Player.GetActiveRecruit().Species);

                                while (species > -1)
                                {

                                    Pokedex.PokemonForm pokemon = Pokedex.Pokedex.GetPokemonForm(species, client.Player.GetActiveRecruit().Form);
                                    if (pokemon != null)
                                    {
                                        for (int n = 0; n < pokemon.LevelUpMoves.Count; n++)
                                        {
                                            if (pokemon.LevelUpMoves[n].Level <= client.Player.GetActiveRecruit().Level)
                                            {
                                                if (pokemon.LevelUpMoves[n].Move == recallMove)
                                                {
                                                    if (client.Player.HasItem(priceItem) >= priceAmount)
                                                    {
                                                        client.Player.TakeItem(priceItem, priceAmount);
                                                        client.Player.GetActiveRecruit().LearnNewMove(recallMove);
                                                        Messenger.SendPlayerMoves(client);
                                                    }
                                                    else
                                                    {
                                                        Messenger.PlayerMsg(client, "You do not have enough to recall a move!", Text.BrightRed);
                                                    }
                                                    return;
                                                }
                                            }
                                        }
                                    }

                                    species = EvolutionManager.FindPreEvolution(species);
                                }
                            }
                            else
                            {
                                Pokedex.PokemonForm pokemon = Pokedex.Pokedex.GetPokemonForm(client.Player.GetActiveRecruit().Species, client.Player.GetActiveRecruit().Form);
                                if (pokemon != null)
                                {
                                    for (int n = 0; n < pokemon.LevelUpMoves.Count; n++)
                                    {
                                        if (pokemon.LevelUpMoves[n].Level <= client.Player.GetActiveRecruit().Level && pokemon.LevelUpMoves[n].Move == recallMove)
                                        {

                                            if (client.Player.HasItem(priceItem) >= priceAmount)
                                            {
                                                client.Player.TakeItem(priceItem, priceAmount);
                                                client.Player.GetActiveRecruit().LearnNewMove(recallMove);
                                                Messenger.SendPlayerMoves(client);
                                            }
                                            else
                                            {
                                                Messenger.PlayerMsg(client, "You do not have enough to recall a move!", Text.BrightRed);
                                            }
                                            return;

                                        }
                                    }

                                }
                            }

                        }
                        break;
                    #endregion
                    #region Bank
                    case "bankdeposit":
                        {
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Bank)
                            {
                                int slot = parse[1].ToInt();
                                int amount = parse[2].ToInt();
                                int X = client.Player.Inventory[slot].Num;
                                string tag = client.Player.Inventory[slot].Tag;
                                int i = client.Player.FindBankSlot(X, amount);
                                if (i == -1)
                                {
                                    Messenger.StorageMessage(client, "The storage is full!");
                                    return;
                                }

                                if (amount > client.Player.Inventory[slot].Amount)
                                {
                                    Messenger.StorageMessage(client, "You cant deposit more than you have!");
                                    return;
                                }

                                if (ItemManager.Items[X].Type == Enums.ItemType.Currency || ItemManager.Items[X].StackCap > 0)
                                {//handle clientside
                                    if (amount <= 0)
                                    {
                                        Messenger.StorageMessage(client, "You must deposit more than 0!");
                                        return;
                                    }
                                }

                                client.Player.TakeItemSlot(slot, amount, true);
                                client.Player.GiveBankItem(X, amount, tag, i);
                            }
                            else
                            {
                                Messenger.HackingAttempt(client, "Player not in Storage");
                            }
                            //Messenger.SendBank(client);
                        }
                        break;
                    case "bankwithdraw":
                        {
                            if (client.Player.Map.Tile[client.Player.X, client.Player.Y].Type == Enums.TileType.Bank)
                            {
                                int slot = parse[1].ToInt();
                                int i = client.Player.Bank[parse[1].ToInt()].Num;
                                string tag = client.Player.Bank[parse[1].ToInt()].Tag;
                                int TempVal = parse[2].ToInt();
                                int X = client.Player.FindInvSlot(i, TempVal);
                                if (X == -1)
                                {
                                    Messenger.StorageMessage(client, "There's no more room in your bag!");
                                    return;
                                }

                                if (TempVal > client.Player.Bank[slot].Amount)
                                {
                                    Messenger.StorageMessage(client, "You cant withdraw more than you have!");
                                    return;
                                }

                                if (ItemManager.Items[i].Type == Enums.ItemType.Currency || ItemManager.Items[i].StackCap > 0)
                                {//handle clientside
                                    if (TempVal <= 0)
                                    {
                                        Messenger.StorageMessage(client, "You must withdraw more than 0!");
                                        return;
                                    }
                                }

                                client.Player.GiveItem(i, TempVal, tag, false);
                                client.Player.TakeBankItem(slot, TempVal);
                            }
                            else
                            {
                                Messenger.HackingAttempt(client, "Player not in Storage");
                            }
                            //Messenger.SendBank(client);
                        }
                        break;
                    case "bankwithdrawmenu":
                        {
                            Messenger.SendBank(client);
                        }
                        break;
                    #endregion
                    #region Custom Menus
                    case "picclick":
                    case "lblclick":
                    case "txtclick":
                    case "menuclosed":
                        client.Player.CustomMenuManager.ProcessTCP(parse);
                        break;
                    #endregion
                    #region Housing
                    case "housevisitrequest":
                        {
                            string ownerName = parse[1];
                            // Now, find the owner ID using the char list...
                            string ownerID;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                            {
                                ownerID = PlayerManager.RetrieveCharacterID(dbConnection, ownerName);
                            }
                            if (!string.IsNullOrEmpty(ownerID))
                            {
                                Messenger.PlayerWarpToHouse(client, ownerID, 0);
                            }
                            else
                            {
                                Messenger.PlayerMsg(client, "There is no house owned by a player of that name.", Text.BrightRed);
                            }
                        }
                        break;
                    case "addshoprequest":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType != Server.Enums.MapType.House || ((House)map).OwnerID != client.Player.CharID)
                            {
                                Messenger.PlayerMsg(client, "You can't place a shop tile here.", Text.BrightRed);
                                return;
                            }
                            int price = parse[1].ToInt();
                            if (client.Player.HasItem(1) < price / House.SHOP_PRICE)
                            {
                                Messenger.PlayerMsg(client, "You need " + price / House.SHOP_PRICE + " " + ItemManager.Items[1].Name + " to place a shop tile.", Text.BrightRed);
                                return;
                            }
                            client.Player.TakeItem(1, price / House.SHOP_PRICE, true);

                            map.Tile[client.Player.X, client.Player.Y].Type = Enums.TileType.DropShop;
                            map.Tile[client.Player.X, client.Player.Y].Data1 = price;
                            map.Tile[client.Player.X, client.Player.Y].Data2 = 0;
                            map.Tile[client.Player.X, client.Player.Y].Data3 = 0;
                            map.Tile[client.Player.X, client.Player.Y].String1 = client.Player.CharID;
                            map.Tile[client.Player.X, client.Player.Y].String2 = "";
                            map.Tile[client.Player.X, client.Player.Y].String3 = "";

                            Messenger.PlayerMsg(client, "A shop tile has been placed!  You can now sell items for " + parse[1].ToInt() + " " + ItemManager.Items[1].Name + " by dropping your items on the tile.", Text.BrightGreen);

                            Messenger.RefreshMap(client);
                        }
                        break;
                    case "addnoticerequest":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType != Server.Enums.MapType.House || ((House)map).OwnerID != client.Player.CharID)
                            {
                                Messenger.PlayerMsg(client, "You can't place a special tile here.", Text.BrightRed);
                                return;
                            }

                            int totalLength = parse[1].Length + parse[2].Length;
                            if (client.Player.HasItem(1) < House.NOTICE_PRICE)
                            {
                                Messenger.PlayerMsg(client, "You need " + (House.NOTICE_PRICE + House.WORD_PRICE * totalLength) + " " + ItemManager.Items[1].Name + " to place a special tile.", Text.BrightRed);
                                return;
                            }
                            client.Player.TakeItem(1, House.NOTICE_PRICE + House.WORD_PRICE * totalLength, true);

                            map.Tile[client.Player.X, client.Player.Y].Type = Enums.TileType.Notice;
                            map.Tile[client.Player.X, client.Player.Y].Data1 = 0;
                            map.Tile[client.Player.X, client.Player.Y].Data2 = 0;
                            map.Tile[client.Player.X, client.Player.Y].Data3 = 0;
                            map.Tile[client.Player.X, client.Player.Y].String1 = parse[1];
                            map.Tile[client.Player.X, client.Player.Y].String2 = parse[2];
                            map.Tile[client.Player.X, client.Player.Y].String3 = parse[3];

                            //Messenger.SendTile(client.Player.X, client.Player.Y, client.Player.Map);
                            Messenger.PlayerMsg(client, "A notice tile has been placed!  Step on it to read what it says.", Text.BrightGreen);

                            Messenger.RefreshMap(client);
                        }
                        break;
                    case "addsoundrequest":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType != Server.Enums.MapType.House || ((House)map).OwnerID != client.Player.CharID)
                            {
                                Messenger.PlayerMsg(client, "You can't place a special tile here.", Text.BrightRed);
                                return;
                            }

                            if (client.Player.HasItem(1) < House.SOUND_PRICE)
                            {
                                Messenger.PlayerMsg(client, "You need " + House.SOUND_PRICE + " " + ItemManager.Items[1].Name + " to place a special tile.", Text.BrightRed);
                                return;
                            }
                            client.Player.TakeItem(1, House.SOUND_PRICE, true);

                            map.Tile[client.Player.X, client.Player.Y].Type = Enums.TileType.Sound;
                            map.Tile[client.Player.X, client.Player.Y].Data1 = 0;
                            map.Tile[client.Player.X, client.Player.Y].Data2 = 0;
                            map.Tile[client.Player.X, client.Player.Y].Data3 = 0;
                            map.Tile[client.Player.X, client.Player.Y].String1 = parse[1];
                            map.Tile[client.Player.X, client.Player.Y].String2 = "";
                            map.Tile[client.Player.X, client.Player.Y].String3 = "";

                            //Messenger.SendTile(client.Player.X, client.Player.Y, client.Player.Map);
                            Messenger.PlayerMsg(client, "A sound tile has been placed!  Step on it to play a sound.", Text.BrightGreen);

                            Messenger.RefreshMap(client);
                        }
                        break;
                    case "addsignrequest":
                        {

                            IMap map = client.Player.Map;
                            if (map.MapType != Server.Enums.MapType.House || ((House)map).OwnerID != client.Player.CharID)
                            {
                                Messenger.PlayerMsg(client, "You can't place a special tile here.", Text.BrightRed);
                                return;
                            }
                            int totalLength = parse[1].Length + parse[2].Length + parse[3].Length;
                            if (client.Player.HasItem(1) < House.WORD_PRICE * totalLength)
                            {
                                Messenger.PlayerMsg(client, "You need " + House.WORD_PRICE * totalLength + " " + ItemManager.Items[1].Name + " to place a special tile.", Text.BrightRed);
                                return;
                            }
                            client.Player.TakeItem(1, House.WORD_PRICE * totalLength, true);

                            map.Tile[client.Player.X, client.Player.Y].Type = Enums.TileType.Sign;
                            map.Tile[client.Player.X, client.Player.Y].Data1 = 0;
                            map.Tile[client.Player.X, client.Player.Y].Data2 = 0;
                            map.Tile[client.Player.X, client.Player.Y].Data3 = 0;
                            map.Tile[client.Player.X, client.Player.Y].String1 = parse[1];
                            map.Tile[client.Player.X, client.Player.Y].String2 = parse[2];
                            map.Tile[client.Player.X, client.Player.Y].String3 = parse[3];

                            //Messenger.SendTile(client.Player.X, client.Player.Y, client.Player.Map);
                            Messenger.PlayerMsg(client, "A sign tile has been placed!  Press Enter to read signs.", Text.BrightGreen);

                            Messenger.RefreshMap(client);
                        }
                        break;
                    case "weatherrequest":
                        {

                            IMap map = client.Player.Map;
                            if (map.MapType != Server.Enums.MapType.House || ((House)map).OwnerID != client.Player.CharID)
                            {
                                Messenger.PlayerMsg(client, "You can't change the weather here.", Text.BrightRed);
                                return;
                            }

                            if (client.Player.HasItem(1) < House.WEATHER_PRICE)
                            {
                                Messenger.PlayerMsg(client, "You need " + House.WEATHER_PRICE + " " + ItemManager.Items[1].Name + " to change the weather.", Text.BrightRed);
                                return;
                            }
                            client.Player.TakeItem(1, House.WEATHER_PRICE, true);

                            map.Weather = (Enums.Weather)parse[1].ToInt();

                            //Messenger.SendTile(client.Player.X, client.Player.Y, client.Player.Map);
                            Messenger.PlayerMsg(client, "The house's weather has been changed!", Text.BrightGreen);

                            Messenger.RefreshMap(client);
                        }
                        break;
                    case "darknessrequest":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType != Server.Enums.MapType.House || ((House)map).OwnerID != client.Player.CharID)
                            {
                                Messenger.PlayerMsg(client, "You can't change the lights here.", Text.BrightRed);
                                return;
                            }

                            if (client.Player.HasItem(1) < House.LIGHT_PRICE)
                            {
                                Messenger.PlayerMsg(client, "You need " + House.LIGHT_PRICE + " " + ItemManager.Items[1].Name + " to change the lights.", Text.BrightRed);
                                return;
                            }
                            client.Player.TakeItem(1, House.LIGHT_PRICE, true);

                            map.Darkness = parse[1].ToInt();

                            //Messenger.SendTile(client.Player.X, client.Player.Y, client.Player.Map);
                            Messenger.PlayerMsg(client, "The house's lights have been changed!", Text.BrightGreen);

                            Messenger.RefreshMap(client);
                        }
                        break;
                    case "expansionrequest":
                        {
                            IMap map = client.Player.Map;
                            if (map.MapType != Server.Enums.MapType.House || ((House)map).OwnerID != client.Player.CharID)
                            {
                                Messenger.PlayerMsg(client, "You can't expand your house here.", Text.BrightRed);
                                return;
                            }
                            int x = parse[1].ToInt();
                            int y = parse[2].ToInt();
                            int total = ((x + 1) * (y + 1) - (map.MaxX + 1) * (map.MaxY + 1)) * House.TILE_PRICE;
                            if (total > 0)
                            {
                                if (client.Player.HasItem(1) < total)
                                {
                                    Messenger.PlayerMsg(client, "You need " + total + " " + ItemManager.Items[1].Name + " to expand your house.", Text.BrightRed);
                                    return;
                                }
                                client.Player.TakeItem(1, total, true);
                            }

                            if (client.Player.X > x) client.Player.X = x;
                            if (client.Player.Y > y) client.Player.Y = y;
                            int oldX = map.MaxX;
                            int oldY = map.MaxY;
                            TileCollection tiles = new TileCollection(map.BaseMap, x, y);

                            for (int Y = 0; Y <= y && Y <= oldY; Y++)
                            {
                                for (int X = 0; X <= x && X <= oldX; X++)
                                {
                                    tiles[X, Y].Ground = map.Tile[X, Y].Ground;
                                    tiles[X, Y].GroundAnim = map.Tile[X, Y].GroundAnim;
                                    tiles[X, Y].Mask = map.Tile[X, Y].Mask;
                                    tiles[X, Y].Anim = map.Tile[X, Y].Anim;
                                    tiles[X, Y].Mask2 = map.Tile[X, Y].Mask2;
                                    tiles[X, Y].M2Anim = map.Tile[X, Y].M2Anim;
                                    tiles[X, Y].Fringe = map.Tile[X, Y].Fringe;
                                    tiles[X, Y].FAnim = map.Tile[X, Y].FAnim;
                                    tiles[X, Y].Fringe2 = map.Tile[X, Y].Fringe2;
                                    tiles[X, Y].F2Anim = map.Tile[X, Y].F2Anim;
                                    tiles[X, Y].Type = map.Tile[X, Y].Type;
                                    tiles[X, Y].Data1 = map.Tile[X, Y].Data1;
                                    tiles[X, Y].Data2 = map.Tile[X, Y].Data2;
                                    tiles[X, Y].Data3 = map.Tile[X, Y].Data3;
                                    tiles[X, Y].String1 = map.Tile[X, Y].String1;
                                    tiles[X, Y].String2 = map.Tile[X, Y].String2;
                                    tiles[X, Y].String3 = map.Tile[X, Y].String3;
                                    tiles[X, Y].RDungeonMapValue = map.Tile[X, Y].RDungeonMapValue;
                                    tiles[X, Y].GroundSet = map.Tile[X, Y].GroundSet;
                                    tiles[X, Y].GroundAnimSet = map.Tile[X, Y].GroundAnimSet;
                                    tiles[X, Y].MaskSet = map.Tile[X, Y].MaskSet;
                                    tiles[X, Y].AnimSet = map.Tile[X, Y].AnimSet;
                                    tiles[X, Y].Mask2Set = map.Tile[X, Y].Mask2Set;
                                    tiles[X, Y].M2AnimSet = map.Tile[X, Y].M2AnimSet;
                                    tiles[X, Y].FringeSet = map.Tile[X, Y].FringeSet;
                                    tiles[X, Y].FAnimSet = map.Tile[X, Y].FAnimSet;
                                    tiles[X, Y].Fringe2Set = map.Tile[X, Y].Fringe2Set;
                                    tiles[X, Y].F2AnimSet = map.Tile[X, Y].F2AnimSet;
                                }
                            }
                            map.Tile = tiles;

                            Messenger.PlayerMsg(client, "The house's boundaries have been changed!", Text.BrightGreen);

                            Messenger.RefreshMap(client);
                        }
                        break;
                    #endregion
                    #region Moves
                    case "overwritemove":
                        {
                            if (client.Player.GetActiveRecruit().LearningMove != -1)
                            {
                                int moveSlot = parse[1].ToInt(-1);
                                if (moveSlot != -1 && moveSlot >= 0 && moveSlot <= 3)
                                {
                                    if (client.Player.GetActiveRecruit().Moves[moveSlot].MoveNum > 0)
                                    {
                                        client.Player.GetActiveRecruit().Moves[moveSlot].MoveNum = client.Player.GetActiveRecruit().LearningMove;
                                        client.Player.GetActiveRecruit().Moves[moveSlot].MaxPP = MoveManager.Moves[client.Player.GetActiveRecruit().Moves[moveSlot].MoveNum].MaxPP;
                                        client.Player.GetActiveRecruit().Moves[moveSlot].CurrentPP = client.Player.GetActiveRecruit().Moves[moveSlot].MaxPP;
                                        Messenger.PlayerMsg(client, "You have learned a new move!", Text.Yellow);
                                        Messenger.SendPlayerMoves(client);
                                    }
                                }
                            }
                        }
                        break;
                    #endregion
                    #region ExpKit
                    case "activekitmodule":
                        {
                            Enums.ExpKitModules module = (Enums.ExpKitModules)parse[1].ToInt();
                            if (client.Player.AvailableExpKitModules.Contains(module))
                            {
                                client.Player.ActiveExpKitModule = module;
                            }
                        }
                        break;
                    #endregion
                    #region Trading
                    case "settradeitem":
                        {
                            if (!string.IsNullOrEmpty(client.Player.TradePartner))
                            {
                                Client tradePartner = ClientManager.FindClientFromCharID(client.Player.TradePartner);
                                if (tradePartner != null && tradePartner.Player.TradePartner == client.Player.CharID)
                                {
                                    int slot = parse[1].ToInt();
                                    int amount = parse[2].ToInt();

                                    if (slot > -1)
                                    {
                                        if (ItemManager.Items[client.Player.Inventory[slot].Num].Type != Enums.ItemType.Currency && ItemManager.Items[client.Player.Inventory[slot].Num].StackCap <= 0)
                                        {
                                            amount = 1;
                                        }
                                        if (ItemManager.Items[client.Player.Inventory[slot].Num].Bound)
                                        {
                                            Messenger.PlayerMsg(client, "This item cannot be traded!", Text.BrightRed);
                                            slot = -1;
                                            amount = 0;
                                        }
                                        else if (client.Player.Inventory[slot].Sticky)
                                        {
                                            Messenger.PlayerMsg(client, "You cannot trade a sticky item!", Text.BrightRed);
                                            slot = -1;
                                            amount = 0;
                                        }
                                        else if (ItemManager.Items[client.Player.Inventory[slot].Num].Rarity > (int)tradePartner.Player.ExplorerRank + 1)
                                        {
                                            Messenger.PlayerMsg(client, "The other person does not have a high enough Explorer Rank to receive this item.", Text.BrightRed);
                                            slot = -1;
                                            amount = 0;
                                        }
                                        else if (amount == 0 && (ItemManager.Items[client.Player.Inventory[slot].Num].Type == Enums.ItemType.Currency || ItemManager.Items[client.Player.Inventory[slot].Num].StackCap > 0))
                                        {
                                            Messenger.PlayerMsg(client, "You must trade more than 0!", Text.BrightRed);
                                            slot = -1;
                                            amount = 0;
                                        }
                                        else if (amount > client.Player.Inventory[slot].Amount && (ItemManager.Items[client.Player.Inventory[slot].Num].Type == Enums.ItemType.Currency || ItemManager.Items[client.Player.Inventory[slot].Num].StackCap > 0))
                                        {
                                            Messenger.PlayerMsg(client, "You cannot trade more than you have!", Text.BrightRed);
                                            slot = -1;
                                            amount = 0;
                                        }
                                        else if (tradePartner.Player.FindInvSlot(client.Player.Inventory[slot].Num) == -1)
                                        {
                                            Messenger.PlayerMsg(client, "The other person does not have enough space to receive this item.", Text.BrightRed);
                                            slot = -1;
                                            amount = 0;
                                        }
                                    }
                                    client.Player.SetTradeItem = slot;
                                    client.Player.SetTradeAmount = amount;

                                    client.Player.ReadyToTrade = false;
                                    tradePartner.Player.ReadyToTrade = false;
                                    Messenger.SendTradeUnconfirm(client);
                                    Messenger.SendTradeUnconfirm(tradePartner);

                                    if (slot > -1)
                                    {
                                        string itemName = Items.ItemManager.Items[client.Player.Inventory[slot].Num].Name;
                                        if (ItemManager.Items[client.Player.Inventory[slot].Num].Type == Enums.ItemType.Currency || ItemManager.Items[client.Player.Inventory[slot].Num].StackCap > 0)
                                        {
                                            itemName += " (" + amount + ")";
                                        }
                                        Messenger.SendTradeSetItemUpdate(tradePartner, client.Player.Inventory[slot].Num, amount, false);
                                        Messenger.SendTradeSetItemUpdate(client, client.Player.Inventory[slot].Num, amount, true);
                                    }
                                    else
                                    {
                                        Messenger.SendTradeSetItemUpdate(tradePartner, -1, 0, false);
                                        Messenger.SendTradeSetItemUpdate(client, -1, 0, true);
                                    }
                                }
                            }
                        }
                        break;
                    case "readytotrade":
                        {
                            if (!string.IsNullOrEmpty(client.Player.TradePartner))
                            {
                                Client tradePartner = ClientManager.FindClientFromCharID(client.Player.TradePartner);
                                if (tradePartner != null && tradePartner.Player.TradePartner == client.Player.CharID)
                                {
                                    int myItem = client.Player.SetTradeItem;
                                    int myAmount = client.Player.SetTradeAmount;
                                    int partnersItem = tradePartner.Player.SetTradeItem;
                                    int partnersAmount = tradePartner.Player.SetTradeAmount;

                                    if (ItemManager.Items[client.Player.Inventory[myItem].Num].Type != Enums.ItemType.Currency && ItemManager.Items[client.Player.Inventory[myItem].Num].StackCap <= 0)
                                    {
                                        myAmount = 1;
                                    }

                                    if (ItemManager.Items[client.Player.Inventory[myItem].Num].Bound)
                                    {
                                        Messenger.PlayerMsg(client, "This item cannot be traded!", Text.BrightRed);
                                        client.Player.SetTradeItem = -1;
                                        client.Player.SetTradeAmount = 0;
                                    }
                                    else if (client.Player.Inventory[myItem].Sticky)
                                    {
                                        Messenger.PlayerMsg(client, "You cannot trade a sticky item!", Text.BrightRed);
                                        client.Player.SetTradeItem = -1;
                                        client.Player.SetTradeAmount = 0;
                                    }
                                    else if (ItemManager.Items[client.Player.Inventory[myItem].Num].Rarity > (int)tradePartner.Player.ExplorerRank + 1)
                                    {
                                        Messenger.PlayerMsg(client, "The other person does not have a high enough Explorer Rank to receive this item.", Text.BrightRed);
                                        client.Player.SetTradeItem = -1;
                                        client.Player.SetTradeAmount = 0;
                                    }
                                    else if (client.Player.SetTradeAmount == 0 && (ItemManager.Items[client.Player.Inventory[myItem].Num].Type == Enums.ItemType.Currency || ItemManager.Items[client.Player.Inventory[myItem].Num].StackCap > 0))
                                    {
                                        Messenger.PlayerMsg(client, "You must trade more than 0!", Text.BrightRed);
                                        client.Player.SetTradeItem = -1;
                                        client.Player.SetTradeAmount = 0;
                                    }
                                    else if (client.Player.SetTradeAmount > client.Player.Inventory[client.Player.SetTradeItem].Amount && (ItemManager.Items[client.Player.Inventory[myItem].Num].Type == Enums.ItemType.Currency || ItemManager.Items[client.Player.Inventory[myItem].Num].StackCap > 0))
                                    {
                                        Messenger.PlayerMsg(client, "You cannot trade more than you have!", Text.BrightRed);
                                        client.Player.SetTradeItem = -1;
                                        client.Player.SetTradeAmount = 0;
                                    }
                                    else if (tradePartner.Player.FindInvSlot(client.Player.Inventory[myItem].Num) == -1)
                                    {
                                        Messenger.PlayerMsg(client, "The other person does not have enough space to receive this item.", Text.BrightRed);
                                        client.Player.SetTradeItem = -1;
                                        client.Player.SetTradeAmount = 0;
                                    }

                                    if (myItem > -1 && partnersItem > -1)
                                    {

                                        client.Player.ReadyToTrade = true;
                                    }
                                    //TODO: Allow Empty Trading

                                    // Both players have confirmed the trade
                                    if (client.Player.ReadyToTrade && tradePartner.Player.ReadyToTrade)
                                    {
                                        // Start the trade!
                                        int clientItemNum = client.Player.Inventory[client.Player.SetTradeItem].Num;
                                        string clientItemTag = client.Player.Inventory[client.Player.SetTradeItem].Tag;
                                        int clientItemAmount = client.Player.SetTradeAmount;
                                        int partnerItemNum = tradePartner.Player.Inventory[tradePartner.Player.SetTradeItem].Num;
                                        string partnerItemTag = tradePartner.Player.Inventory[tradePartner.Player.SetTradeItem].Tag;
                                        int partnerItemAmount = tradePartner.Player.SetTradeAmount;

                                        tradePartner.Player.ReadyToTrade = false;
                                        client.Player.ReadyToTrade = false;

                                        // Take items from both players.
                                        client.Player.TakeItemSlot(client.Player.SetTradeItem, clientItemAmount, true);
                                        tradePartner.Player.TakeItemSlot(tradePartner.Player.SetTradeItem, partnerItemAmount, true);
                                        // Give items to both players
                                        client.Player.GiveItem(partnerItemNum, partnerItemAmount, partnerItemTag);
                                        tradePartner.Player.GiveItem(clientItemNum, clientItemAmount, clientItemTag);
                                        // Save both players' inventory to prevent cloning!
                                        using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
                                        {
                                            client.Player.SaveCharacterData(dbConnection);
                                            tradePartner.Player.SaveCharacterData(dbConnection);
                                        }

                                        //Messenger.SendInventoryUpdate(client, client.Player.SetTradeItem);
                                        //Messenger.SendInventoryUpdate(tradePartner, tradePartner.Player.SetTradeItem);

                                        client.Player.SetTradeItem = -1;
                                        client.Player.SetTradeAmount = 0;
                                        tradePartner.Player.SetTradeItem = -1;
                                        tradePartner.Player.SetTradeAmount = 0;

                                        Messenger.SendTradeComplete(client);
                                        Messenger.SendTradeComplete(tradePartner);
                                    }

                                }
                            }
                        }
                        break;
                    case "endplayertrade":
                        {
                            client.Player.EndTrade(true);
                        }
                        break;
                    #endregion
                    #region Tournament
                    case "jointournament":
                        {
                            Tournament tourny = TournamentManager.Tournaments[parse[1]];
                            if (tourny != null)
                            {
                                tourny.RegisterPlayer(client);
                            }
                        }
                        break;
                    case "viewtournamentrules":
                        {
                            Tournament tourny = TournamentManager.Tournaments[parse[1]];
                            if (tourny != null)
                            {
                                Messenger.SendTournamentRulesTo(client, null, tourny);
                            }
                        }
                        break;
                    case "savetournamentrules":
                        {
                            Tournament tourny = client.Player.Tournament;
                            if (tourny != null)
                            {
                                if (tourny.RegisteredMembers[client].Admin)
                                {
                                    tourny.Rules.SleepClause = parse[1].ToBool();
                                    tourny.Rules.AccuracyClause = parse[2].ToBool();
                                    tourny.Rules.SpeciesClause = parse[3].ToBool();
                                    tourny.Rules.FreezeClause = parse[4].ToBool();
                                    tourny.Rules.OHKOClause = parse[5].ToBool();
                                    tourny.Rules.SelfKOClause = parse[6].ToBool();
                                }
                            }
                        }
                        break;
                    case "spectatetournament":
                        {
                            Tournament tourny = TournamentManager.Tournaments[parse[1]];
                            if (client.Player.Tournament != null)
                            {
                                Tournament playerTourny = client.Player.Tournament;
                                playerTourny.RegisteredMembers.Remove(client);
                            }
                            tourny.RegisterSpectator(client);
                        }
                        break;
                    #endregion
                }
                #endregion

            }
        }
 public void Add(Story story)
 {
     cache.Add(story);
 }