Beispiel #1
0
        public void EndTempStatMode()
        {
            PacketHitList hitlist = null;
            PacketHitList.MethodStart(ref hitlist);

            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                for (int i = 0; i < Team.Length; i++) {
                    if (Team[i].Loaded && Team[i].InTempMode) {
                        int recruitIndex = Team[i].RecruitIndex;
                        Team[i] = new Recruit(client);
                        RecruitData recruitData = PlayerDataManager.LoadPlayerRecruit(dbConnection.Database, CharID, recruitIndex, false);
                        Team[i].LoadFromRecruitData(recruitData, recruitIndex);
                        PlayerDataManager.DeletePlayerRecruit(dbConnection.Database, CharID, recruitIndex, true);
                    }
                }
            }

            PacketBuilder.AppendPlayerData(client, hitlist);
            PacketBuilder.AppendStats(client, hitlist);
            PacketBuilder.AppendEXP(client, hitlist);

            PacketBuilder.AppendPlayerMoves(client, hitlist);
            PacketBuilder.AppendActiveTeam(client, hitlist);
        }
Beispiel #2
0
 //public int GetTeamSize() {
 //    int total = 0;
 //    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
 //        if (team[i].Loaded) {
 //            if (team[i].RecruitIndex > -1 || team[i].RecruitBoost == -2) {
 //                total += team[i].Size;
 //            }
 //        }
 //    }
 //    return total;
 //}
 public void AddToTeam(int recruitIndex, int teamSlot)
 {
     using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
         if (((recruitIndex > -1 && IsInTeam(recruitIndex) == false && RecruitExists(dbConnection, recruitIndex)) || recruitIndex == -2) && (!(teamSlot < 0) || !(teamSlot > 3))) {
             Recruit recruit = new Recruit(client);
             recruit.LoadFromRecruitData(PlayerDataManager.LoadPlayerRecruit(dbConnection.Database, CharID, recruitIndex, false), recruitIndex);
             team[teamSlot] = recruit;
             for (int i = 0; i < team.Length; i++) {
                 if (team[i].RecruitIndex != -1) {
                     team[i].LoadActiveItemList();
                 }
             }
             if (recruitIndex != -2) {
                 ScriptManager.InvokeSub("RecruitAddedToTeam", client, teamSlot, recruitIndex);
             }
         }
     }
 }
Beispiel #3
0
        public Recruit CreateRecruitFromNpc(MapNpc npc)
        {
            Recruit recruit = new Recruit(client);

            recruit.Name = npc.Name;
            recruit.Species = npc.Species;
            recruit.Form = npc.Form;
            recruit.Sex = npc.Sex;

            if (npc.Level <= 0) {
                recruit.Level = 1;//NpcRec.RecruitLevel;
            } else {
                recruit.Level = npc.Level;
            }
            recruit.Exp = 0;
            recruit.IQ = 0;
            recruit.NpcBase = npc.Num;
            recruit.AtkBonus = npc.AtkBonus;
            recruit.DefBonus = npc.DefBonus;
            recruit.SpclAtkBonus = npc.SpclAtkBonus;
            recruit.SpclDefBonus = npc.SpclDefBonus;
            recruit.SpdBonus = npc.SpdBonus;
            recruit.MaxHPBonus = npc.MaxHPBonus;
            for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                recruit.Moves[i].MoveNum = npc.Moves[i].MoveNum;
                recruit.Moves[i].MaxPP = npc.Moves[i].MaxPP;
            }

            return recruit;
        }
Beispiel #4
0
        internal void AddToRequested(MapNpc npc)
        {
            if (requestedRecruit == null) {
                requestedRecruit = new Recruit(client);
            }
            requestedRecruit = CreateRecruitFromNpc(npc);
            //requestedRecruit.Name = npc.Name;
            //requestedRecruit.Species = npc.Species;
            //requestedRecruit.Form = npc.Form;
            //requestedRecruit.Sex = npc.Sex;
            Pokedex.PokemonForm pokemon = Pokedex.Pokedex.GetPokemonForm(npc.Species, npc.Form);

            //if (npc.Level <= 0) {
            //    requestedRecruit.Level = 1;//NpcRec.RecruitLevel;
            //} else {
            //    requestedRecruit.Level = npc.Level;
            //}
            //requestedRecruit.Exp = 0;
            //requestedRecruit.IQ = 0;
            //requestedRecruit.NpcBase = npc.Num;
            //requestedRecruit.AtkBonus = npc.AtkBonus;
            //requestedRecruit.DefBonus = npc.DefBonus;
            //requestedRecruit.SpclAtkBonus = npc.SpclAtkBonus;
            //requestedRecruit.SpclDefBonus = npc.SpclDefBonus;
            //requestedRecruit.SpdBonus = npc.SpdBonus;
            //requestedRecruit.MaxHPBonus = npc.MaxHPBonus;
            //for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
            //    requestedRecruit.Moves[i].MoveNum = npc.Moves[i].MoveNum;
            //    requestedRecruit.Moves[i].MaxPP = npc.Moves[i].MaxPP;
            //}

            Hunted = false;
            if (pokemon != null) {
                Messenger.AskQuestion(client, "RecruitPokemon", requestedRecruit.Name + " wants to join your team! Will you accept it?", requestedRecruit.Species);
            } else {
                Messenger.AskQuestion(client, "RecruitPokemon", requestedRecruit.Name + " wants to join your team! Will you accept it?", -1);
            }
        }
Beispiel #5
0
        public int AddToRecruitmentBank(DatabaseConnection dbConnection, Recruit requestedRecruit)
        {
            int index = FindOpenRecruitmentSlot(dbConnection);
            if (index > -1 && index <= Constants.MAX_RECRUITMENTS) {

                PokemonCaught(requestedRecruit.Species);

                Recruit recruit = new Recruit(client);
                recruit.RecruitIndex = index;
                recruit.Level = requestedRecruit.Level;
                recruit.Species = requestedRecruit.Species;
                recruit.Form = requestedRecruit.Form;
                recruit.Sex = requestedRecruit.Sex;
                recruit.CalculateOriginalStats();
                recruit.Exp = requestedRecruit.Exp;
                recruit.IQ = requestedRecruit.IQ;
                //recruit.HP = recruit.MaxHP;
                recruit.Name = requestedRecruit.Name;
                recruit.NpcBase = requestedRecruit.NpcBase;
                recruit.AtkBonus = requestedRecruit.AtkBonus;
                recruit.DefBonus = requestedRecruit.DefBonus;
                recruit.SpclAtkBonus = requestedRecruit.SpclAtkBonus;
                recruit.SpclDefBonus = requestedRecruit.SpclDefBonus;
                recruit.SpdBonus = requestedRecruit.SpdBonus;
                recruit.MaxHPBonus = requestedRecruit.MaxHPBonus;

                for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                    recruit.Moves[i].MoveNum = requestedRecruit.Moves[i].MoveNum;
                    recruit.Moves[i].MaxPP = requestedRecruit.Moves[i].MaxPP;
                    recruit.Moves[i].CurrentPP = recruit.Moves[i].MaxPP;
                    recruit.Moves[i].Sealed = false;
                }
                recruit.Save(dbConnection);
                //Return the index of the recruited player
                return index;
            }
            //Return -1 so we know we're full
            return -1;
        }
Beispiel #6
0
 public void RemoveFromTeam(int teamSlot)
 {
     if (teamSlot > 0 && teamSlot < 4 && team[teamSlot].Loaded) {
         ScriptManager.InvokeSub("BeforeRecruitRemovedFromTeam", client, teamSlot);
         //if (ActiveMission != null) {
         //    if (ActiveMission.WonderMail.MissionType == Enums.MissionType.Escort) {
         //        if (team[teamSlot].RecruitIndex == -2 && missionFailed) {
         //            Messenger.PlayerMsg(client, team[teamSlot].Name + " has went home. The mission has ended.", Text.Yellow);
         //            if (Settings.Scripting) {
         //                Scripting.ScriptManager.InvokeSub("OnMissionFailed", client, ActiveMission);
         //            }
         //            for (int i = 0; i < JobList.JobList.Count; i++) {
         //                JobList.JobList[i].Accepted = false;
         //            }
         //            activeMission = null;
         //            Messenger.SendMissionComplete(client);
         //            Messenger.SendJobList(client);
         //        }
         //    }
         //}
         if (teamSlot == ActiveSlot) {
             SwapActiveRecruit(0, true);
         }
         if (team[teamSlot].RecruitIndex > -1) {
             if (team[teamSlot].InTempMode) {
                 RestoreRecruitStats(teamSlot);
             } else {
                 using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                     team[teamSlot].Save(dbConnection);
                 }
             }
         }
         team[teamSlot] = new Recruit(client);
         ScriptManager.InvokeSub("RecruitRemovedFromTeam", client, teamSlot);
         Messenger.SendActiveTeam(client);
     }
 }
Beispiel #7
0
 public void RestoreRecruitStats(int slot)
 {
     if (Team[slot].Loaded && Team[slot].InTempMode) {
         int recruitIndex = Team[slot].RecruitIndex;
         Team[slot] = new Recruit(client);
         using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
             RecruitData recruitData = PlayerDataManager.LoadPlayerRecruit(dbConnection.Database, CharID, recruitIndex, false);
             Team[slot].LoadFromRecruitData(recruitData, recruitIndex);
             PlayerDataManager.DeletePlayerRecruit(dbConnection.Database, CharID, recruitIndex, true);
         }
     }
 }
Beispiel #8
0
        public bool LoadCharacter(DatabaseConnection dbConnection, int characterSlot)
        {
            dataLock.EnterReadLock();
            bool result = false;
            string characterID = PlayerDataManager.RetrieveAccountCharacterID(dbConnection.Database, accountName, characterSlot);
            if (!string.IsNullOrEmpty(characterID)) {
                playerData = new PlayerData(characterID);
                PlayerDataManager.LoadPlayerData(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStatistics(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerMissionBoardMissions(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStoryHelperStateSettings(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerJobList(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerTriggerEvents(dbConnection.Database, playerData);

                inventory = new Inventory(playerData.Inventory);
                bank = new Inventory(playerData.Bank);

                // Load available ExpKit modules
                if (string.IsNullOrEmpty(playerData.AvailableModules)) {
                    AddEnabledExpKitModules();
                } else {
                    string[] modules = playerData.AvailableModules.Split(';');
                    availableExpKitModules = new AvailableExpKitModuleCollection(modules.Length);
                    AddEnabledExpKitModules();
                    for (int i = 0; i < modules.Length; i++) {
                        if (modules[i].IsNumeric()) {
                            if (availableExpKitModules.Contains((Enums.ExpKitModules)modules[i].ToInt()) == false) {
                                availableExpKitModules.Add(new AvailableExpKitModule((Enums.ExpKitModules)modules[i].ToInt(), false));
                            }
                        }
                    }
                }

                // Load statistics - Statistics data is inherited from PlayerData
                statistics = new Statistics.PlayerStatistics(this);

                // Load mission board data
                missionBoard = new WonderMails.MissionBoard(this);
                missionBoard.LoadMissionBoardData();
                missionBoard.UpdateMissionBoard();

                // Load joblist
                jobList = new WonderMailTasks(this);
                jobList.LoadJobList(playerData.JobList);

                //load mission goals [HIGH]
                goalPoints = new List<GoalPoint>();

                // Load story helper
                storyHelper = new StoryHelper(this);

                // Load trigger events [HIGH]
                triggerEvents = new List<Events.Player.TriggerEvents.ITriggerEvent>();

                // Load player team
                team = new Recruit[playerData.TeamMembers.Length];
                for (int i = 0; i < playerData.TeamMembers.Length; i++) {
                    team[i] = new Recruit(client);
                }
                for (int i = 0; i < playerData.TeamMembers.Length; i++) {
                    if (playerData.TeamMembers[i].RecruitIndex != -1) {
                        RecruitData recruitData = PlayerDataManager.LoadPlayerRecruit(dbConnection.Database, CharID, playerData.TeamMembers[i].RecruitIndex, playerData.TeamMembers[i].UsingTempStats);
                        if (recruitData != null) {
                            team[i].LoadFromRecruitData(recruitData, playerData.TeamMembers[i].RecruitIndex);
                        } else {
                            playerData.TeamMembers[i].RecruitIndex = -1;
                        }
                    }
                }

                for (int i = 0; i < playerData.TeamMembers.Length; i++) {
                    if (team[i].RecruitIndex != -1) {
                        team[i].LoadActiveItemList();
                    }
                }

                // Set the explorer rank
                while (ExplorerRank != Enums.ExplorerRank.Guildmaster && MissionExp >= MissionManager.DetermineMissionExpRequirement(ExplorerRank + 1)) {
                    ExplorerRank++;
                }

                if (MapID.IsNumeric()) {
                    int mapNum = MapID.ToInt();
                    if (mapNum == -2) {
                        MapID = MapManager.GenerateMapID(Settings.Crossroads);
                    } else {
                        MapID = "s" + MapID;
                    }
                }
                //            if (string.IsNullOrEmpty(this.id)) {
                //                id = PlayerID.GeneratePlayerID();
                //            }
                //PlayerID.AddPlayerToIndexList(CharID, client.TcpID);

                loaded = true;
            }

            dataLock.ExitReadLock();
            return result;
        }
Beispiel #9
0
        public bool LoadCharacter(DatabaseConnection dbConnection, int characterSlot)
        {
            dataLock.EnterReadLock();
            bool   result      = false;
            string characterID = PlayerDataManager.RetrieveAccountCharacterID(dbConnection.Database, accountName, characterSlot);

            if (!string.IsNullOrEmpty(characterID))
            {
                playerData = new PlayerData(characterID);
                PlayerDataManager.LoadPlayerData(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStatistics(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerMissionBoardMissions(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStoryHelperStateSettings(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerJobList(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerTriggerEvents(dbConnection.Database, playerData);

                inventory = new Inventory(playerData.Inventory);
                bank      = new Inventory(playerData.Bank);

                // Load available ExpKit modules
                if (string.IsNullOrEmpty(playerData.AvailableModules))
                {
                    AddEnabledExpKitModules();
                }
                else
                {
                    string[] modules = playerData.AvailableModules.Split(';');
                    availableExpKitModules = new AvailableExpKitModuleCollection(modules.Length);
                    AddEnabledExpKitModules();
                    for (int i = 0; i < modules.Length; i++)
                    {
                        if (modules[i].IsNumeric())
                        {
                            if (availableExpKitModules.Contains((Enums.ExpKitModules)modules[i].ToInt()) == false)
                            {
                                availableExpKitModules.Add(new AvailableExpKitModule((Enums.ExpKitModules)modules[i].ToInt(), false));
                            }
                        }
                    }
                }

                // Load statistics - Statistics data is inherited from PlayerData
                statistics = new Statistics.PlayerStatistics(this);

                // Load mission board data
                missionBoard = new WonderMails.MissionBoard(this);
                missionBoard.LoadMissionBoardData();
                missionBoard.UpdateMissionBoard();

                // Load joblist
                jobList = new WonderMailTasks(this);
                jobList.LoadJobList(playerData.JobList);

                //load mission goals [HIGH]
                goalPoints = new List <GoalPoint>();

                // Load story helper
                storyHelper = new StoryHelper(this);

                // Load trigger events [HIGH]
                triggerEvents = new List <Events.Player.TriggerEvents.ITriggerEvent>();

                // Load player team
                team = new Recruit[playerData.TeamMembers.Length];
                for (int i = 0; i < playerData.TeamMembers.Length; i++)
                {
                    team[i] = new Recruit(client);
                }
                for (int i = 0; i < playerData.TeamMembers.Length; i++)
                {
                    if (playerData.TeamMembers[i].RecruitIndex != -1)
                    {
                        RecruitData recruitData = PlayerDataManager.LoadPlayerRecruit(dbConnection.Database, CharID, playerData.TeamMembers[i].RecruitIndex, playerData.TeamMembers[i].UsingTempStats);
                        if (recruitData != null)
                        {
                            team[i].LoadFromRecruitData(recruitData, playerData.TeamMembers[i].RecruitIndex);
                        }
                        else
                        {
                            playerData.TeamMembers[i].RecruitIndex = -1;
                        }
                    }
                }

                for (int i = 0; i < playerData.TeamMembers.Length; i++)
                {
                    if (team[i].RecruitIndex != -1)
                    {
                        team[i].LoadActiveItemList();
                    }
                }

                // Set the explorer rank
                while (ExplorerRank != Enums.ExplorerRank.Guildmaster && MissionExp >= MissionManager.DetermineMissionExpRequirement(ExplorerRank + 1))
                {
                    ExplorerRank++;
                }

                if (MapID.IsNumeric())
                {
                    int mapNum = MapID.ToInt();
                    if (mapNum == -2)
                    {
                        MapID = MapManager.GenerateMapID(Settings.Crossroads);
                    }
                    else
                    {
                        MapID = "s" + MapID;
                    }
                }
                //            if (string.IsNullOrEmpty(this.id)) {
                //                id = PlayerID.GeneratePlayerID();
                //            }
                //PlayerID.AddPlayerToIndexList(CharID, client.TcpID);

                loaded = true;
            }

            dataLock.ExitReadLock();
            return(result);
        }
Beispiel #10
0
        public static void StoryScript(Client client, int scriptNum, string param1, string param2, string param3, bool paused)
        {
            // Called when a script from a story is run
            try {

            switch (scriptNum) {
                case 0: {
                        Messenger.SendPlayerData(client);
                    }
                    break;
                case 1: {
                        if (client.Player.Map.MapType != Enums.MapType.Instanced) return;
                        InstancedMap map = client.Player.Map as InstancedMap;
                        MapNpcPreset npc = new MapNpcPreset();
                        string[] loc = param1.Split(':');

                        string[] lvl = param3.Split(':');
                        npc.SpawnX = loc[0].ToInt();
                        npc.SpawnY = loc[1].ToInt();
                        npc.NpcNum = param2.ToInt();
                        npc.MinLevel = lvl[0].ToInt(); // TODO: Adjust npc level
                        npc.MaxLevel = lvl[1].ToInt(); // TODO: Adjust npc level
                        //Messenger.AdminMsg(npc.SpawnX+"/"+npc.SpawnY+"/"+npc.NpcNum+"/"+npc.MinLevel+"/"+npc.MaxLevel, Text.Pink);
                        map.SpawnNpc(npc);

                    }
                    break;
                case 2: {
                        if (client.Player.Map.MapType != Enums.MapType.Instanced) return;
                        InstancedMap map = client.Player.Map as InstancedMap;
                        string[] loc = param1.Split(':');
                        map.SetTile(loc[0].ToInt(), loc[1].ToInt(), 3, 4, 3);
                        map.SetAttribute(loc[0].ToInt(), loc[1].ToInt(), Enums.TileType.Scripted, 46, 0, 0, param2, "-1", "");
                        Messenger.SendTile(loc[0].ToInt(), loc[1].ToInt(), map);
                    }
                    break;
                case 3: {
                        if (client.Player.Map.MapType != Enums.MapType.Instanced) return;
                        InstancedMap map = client.Player.Map as InstancedMap;
                        string[] loc = param1.Split(':');
                        string[] dest = param2.Split(':');
                        map.SetTile(loc[0].ToInt(), loc[1].ToInt(), 3, 4, 3);
                        map.SetAttribute(loc[0].ToInt(), loc[1].ToInt(), Enums.TileType.Warp, dest[0].ToInt(), dest[1].ToInt(), dest[2].ToInt(), "", "", "");
                        Messenger.SendTile(loc[0].ToInt(), loc[1].ToInt(), map);
                    }
                    break;
                case 4: {
                        IMap map = client.Player.Map;
                        map.Npc[1].SpawnX = 9;
                        map.Npc[1].SpawnY = 7;
                        map.Npc[2].SpawnX = 6;
                        map.Npc[2].SpawnY = 11;
                        map.Npc[3].SpawnX = 13;
                        map.Npc[3].SpawnY = 11;
                        map.Npc[1].NpcNum = 306;
                        map.Npc[2].NpcNum = 259;
                        map.Npc[3].NpcNum = 259;
                        //map.SetNpc(0, 500);
                        //map.SetNpc(1, 500);
                        //map.SetNpc(2, 500);
                        for (int i = 1; i <= 3; i++) {
                            //map.SpawnNpc(i);
                        }
                    }
                    break;
                case 5: {
                        //sound
                        Messenger.PlaySoundToMap(client.Player.Map.MapID, param1);
                    }
                    break;
                case 6: {
                        IMap map = client.Player.Map;
                        map.Npc[1].SpawnX = 9;
                        map.Npc[1].SpawnY = 3;
                        map.Npc[1].NpcNum = 337;
                        //map.SpawnNpc(1);
                    }
                    break;
                case 7: {// Luxio Tribe Battle
                        // 167 - Luxio
                        // 177 - Luxray
                        // 5 luxio, 1 luxray
                        IMap map = client.Player.Map;
                        map.Npc[1].SpawnX = 10;
                        map.Npc[1].SpawnY = 5;
                        map.Npc[2].SpawnX = 7;
                        map.Npc[2].SpawnY = 6;
                        map.Npc[3].SpawnX = 12;
                        map.Npc[3].SpawnY = 6;
                        map.Npc[4].SpawnX = 7;
                        map.Npc[4].SpawnY = 8;
                        map.Npc[5].SpawnX = 12;
                        map.Npc[5].SpawnY = 8;
                        map.Npc[6].SpawnX = 12;
                        map.Npc[6].SpawnY = 9;
                        map.Npc[7].SpawnX = 10;
                        map.Npc[7].SpawnY = 7;
                        map.Npc[1].NpcNum = 177;
                        for (int i = 2; i <= 7; i++) {
                            map.Npc[i].NpcNum = 167;
                        }
                        for (int i = 1; i <= 7; i++) {
                            //map.SpawnNpc(i);
                        }
                    }
                    break;
                case 8: {
                        client.Player.GiveItem(159, 1);
                    }
                    break;
                case 9: {
                        client.Player.SetStoryState(157, false);
                    }
                    break;
                case 10: {//Start Registeel Battle: First wave of bronzongs
                        BossBattles.StartBossWave(client, "Registeel", 1);
                    }
                    break;
                case 11: {//Registeel Battle: second wave of bronzongs
                        BossBattles.StartBossWave(client, "Registeel", 2);
                    }
                    break;
                case 12: {//Registeel Battle: Registeel itself
                        BossBattles.StartBossWave(client, "Registeel", 3);
                    }
                    break;
                case 13: {//leaving Forlorn Tower by fee
                        int amount = client.Player.HasItem(1);
                        if (amount > 0) {
                            client.Player.TakeItem(1, (amount / 2));
                        }
                        Messenger.PlayerWarp(client, 684, 13, 20);
                    }
                    break;
                case 14: {
                        if (exPlayer.Get(client).StoryEnabled) {
                            int currentSection = client.Player.StoryHelper.ReadSetting("[MainStory]-CurrentSection").ToInt();
                            client.Player.StoryHelper.SaveSetting("[MainStory]-CurrentSection", (currentSection + 1).ToString());
                        }
                    }
                    break;
                case 15: {//murkrows attack (wave 1)
                        IMap map = client.Player.Map;

                        map.SetAttribute(7, 10, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(13, 10, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(7, 14, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(13, 14, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(4, 18, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(16, 18, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(4, 8, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(16, 8, Enums.TileType.Scripted, 3, 0, 0, "", "", "");

                        map.SetNpcSpawnPoint(1, 3, 10);
                        map.SetNpcSpawnPoint(2, 4, 11);
                        map.SetNpcSpawnPoint(3, 6, 10);
                        map.SetNpcSpawnPoint(4, 7, 11);
                        map.SetNpcSpawnPoint(5, 8, 10);
                        map.SetNpcSpawnPoint(6, 9, 11);
                        map.SetNpcSpawnPoint(7, 10, 10);
                        map.SetNpcSpawnPoint(8, 11, 11);
                        map.SetNpcSpawnPoint(9, 12, 10);
                        map.SetNpcSpawnPoint(10, 13, 11);
                        map.SetNpcSpawnPoint(11, 14, 10);
                        map.SetNpcSpawnPoint(12, 16, 11);
                        map.SetNpcSpawnPoint(13, 17, 10);

                        for (int i = 1; i <= 13; i++) {
                            map.Npc[i].NpcNum = 224;
                        }

                        //map.SpawnNpc(1);
                        //map.SpawnNpc(2);
                        //map.SpawnNpc(3);
                        //map.SpawnNpc(4);
                        //map.SpawnNpc(5);
                        //map.SpawnNpc(6);
                        //map.SpawnNpc(7);
                        //map.SpawnNpc(8);
                        //map.SpawnNpc(9);
                        //map.SpawnNpc(10);
                        //map.SpawnNpc(11);
                        //map.SpawnNpc(12);
                        //map.SpawnNpc(13);

                    }
                    break;
                case 16: {//murkrows attack (ambush)
                        IMap map = client.Player.Map;

                        map.SetAttribute(7, 10, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(13, 10, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(7, 14, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(13, 14, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(4, 18, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(16, 18, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(4, 8, Enums.TileType.Scripted, 3, 0, 0, "", "", "");
                        map.SetAttribute(16, 8, Enums.TileType.Scripted, 3, 0, 0, "", "", "");

                        map.SetNpcSpawnPoint(1, 9, 7);
                        map.SetNpcSpawnPoint(2, 10, 7);
                        map.SetNpcSpawnPoint(3, 11, 7);
                        map.SetNpcSpawnPoint(4, 9, 8);
                        map.SetNpcSpawnPoint(5, 11, 8);
                        map.SetNpcSpawnPoint(6, 9, 9);
                        map.SetNpcSpawnPoint(7, 10, 9);
                        map.SetNpcSpawnPoint(8, 11, 9);
                        map.SetNpcSpawnPoint(9, 8, 8);
                        map.SetNpcSpawnPoint(10, 8, 9);
                        map.SetNpcSpawnPoint(11, 12, 8);
                        map.SetNpcSpawnPoint(12, 12, 9);
                        map.SetNpcSpawnPoint(13, 10, 10);

                        for (int i = 1; i <= 13; i++) {
                            map.Npc[i].NpcNum = 220;
                        }

                        //map.SpawnNpc(1);
                        //map.SpawnNpc(2);
                        //map.SpawnNpc(3);
                        //map.SpawnNpc(4);
                        //map.SpawnNpc(5);
                        //map.SpawnNpc(6);
                        //map.SpawnNpc(7);
                        //map.SpawnNpc(8);
                        //map.SpawnNpc(9);
                        //map.SpawnNpc(10);
                        //map.SpawnNpc(11);
                        //map.SpawnNpc(12);
                        //map.SpawnNpc(13);

                        if (client.Player.GetActiveRecruit().HeldItem.Num != 142) {
                            Messenger.BattleMsg(client, "There was a trap underneath!", Text.BrightRed);
                            Messenger.BattleMsg(client, "The trap exploded!", Text.BrightRed);
                            //Messenger.SpellAnim(497, client.Player.MapID, client.Player.X, client.Player.Y);
                            //DamagePlayer(client, Convert.ToInt32((client.Player.GetActiveRecruit().HP + 0.5) / 2), Enums.KillType.Npc);

                            Messenger.PlaySoundToMap(client.Player.MapID, "magic64.wav");
                            Messenger.BattleMsg(client, "The trap drained all your PP!", Text.BrightRed);
                            //Messenger.SpellAnim(493, client.Player.MapID, client.Player.X, client.Player.Y);
                            for (int i = 0; i < client.Player.GetActiveRecruit().Moves.Length; i++) {
                                client.Player.GetActiveRecruit().Moves[i].CurrentPP = 0;
                                //Messenger.SendMovePPUpdate(client, i);
                            }
                            Messenger.PlaySound(client, "PP Zero.wav");
                            Messenger.BattleMsg(client, "Poison spikes shot out!", Text.BrightRed);
                            //Messenger.SpellAnim(496, client.Player.MapID, client.Player.X, client.Player.Y);
                            Messenger.PlaySoundToMap(client.Player.MapID, "magic23.wav");
                            SetStatusAilment(client.Player.GetActiveRecruit(), client.Player.Map, Enums.StatusAilment.Poison, 1, null);
                            Messenger.BattleMsg(client, "Mud splashed up from the ground!", Text.BrightRed);
                            //Messenger.SpellAnim(495, client.Player.MapID, client.Player.X, client.Player.Y);
                            Messenger.PlaySoundToMap(client.Player.MapID, "magic65.wav");
                            switch (Server.Math.Rand(0, 4)) {
                                case 0: {
                                        client.Player.GetActiveRecruit().AttackBuff = 0;
                                    }
                                    break;
                                case 1: {
                                        client.Player.GetActiveRecruit().DefenseBuff = 0;
                                    }
                                    break;
                                case 2: {
                                        client.Player.GetActiveRecruit().SpAtkBuff = 0;
                                    }
                                    break;
                                case 3: {
                                        client.Player.GetActiveRecruit().SpeedBuff = 0;
                                    }
                                    break;
                            }
                            //Messenger.SpellAnim(494, client.Player.MapID, client.Player.X, client.Player.Y);
                            //Grimy(client);
                            Messenger.PlaySoundToMap(client.Player.MapID, "Magic65.wav");
                            //PlayerInvDrop(client);
                            Messenger.MapMsg(client.Player.MapID, client.Player.Name + " tripped!", Text.BrightRed);
                            Messenger.PlaySoundToMap(client.Player.MapID, "magic55.wav");
                            Messenger.BattleMsg(client, "You were pelted with chestnuts!", Text.BrightRed);
                            //DamagePlayer(client, 50, Enums.KillType.Npc);

                            Messenger.PlaySoundToMap(client.Player.MapID, "pain.wav");
                            Messenger.BattleMsg(client, "The trap broke down...", Text.Black);
                        }
                    }
                    break;
                case 17: {//murkrows and honchkrow attack
                        IMap map = client.Player.Map;
                        map.SetNpcSpawnPoint(1, 6, 9);
                        map.SetNpcSpawnPoint(2, 14, 9);
                        map.SetNpcSpawnPoint(3, 6, 11);
                        map.SetNpcSpawnPoint(4, 14, 11);
                        map.SetNpcSpawnPoint(5, 5, 13);
                        map.SetNpcSpawnPoint(6, 15, 13);
                        map.SetNpcSpawnPoint(7, 6, 15);
                        map.SetNpcSpawnPoint(8, 14, 15);
                        map.SetNpcSpawnPoint(9, 8, 14);
                        map.SetNpcSpawnPoint(10, 12, 14);
                        map.SetNpcSpawnPoint(11, 6, 18);
                        map.SetNpcSpawnPoint(12, 14, 18);
                        map.SetNpcSpawnPoint(13, 10, 16);
                        map.SetNpcSpawnPoint(14, 10, 7);

                        map.SetNpc(1, 220);
                        map.SetNpc(2, 220);
                        map.SetNpc(3, 220);
                        map.SetNpc(4, 220);
                        map.SetNpc(5, 220);
                        map.SetNpc(6, 220);
                        map.SetNpc(7, 220);
                        map.SetNpc(8, 220);
                        map.SetNpc(9, 220);
                        map.SetNpc(10, 220);
                        map.SetNpc(11, 220);
                        map.SetNpc(12, 220);
                        map.SetNpc(13, 220);
                        map.SetNpc(14, 221);

                        //map.SpawnNpc(1);
                        //map.SpawnNpc(2);
                        //map.SpawnNpc(3);
                        //map.SpawnNpc(4);
                        //map.SpawnNpc(5);
                        //map.SpawnNpc(6);
                        //map.SpawnNpc(7);
                        //map.SpawnNpc(8);
                        //map.SpawnNpc(9);
                        //map.SpawnNpc(10);
                        //map.SpawnNpc(11);
                        //map.SpawnNpc(12);
                        //map.SpawnNpc(13);
                        //map.SpawnNpc(14);

                    }
                    break;
                case 18: {//honchkrow defeated, warp opens.
                        IMap map = client.Player.Map;
                        map.SetTile(10, 6, 96, 4, 3);
                        map.SetTile(10, 5, 112576, 9, 3);
                        map.SetTile(10, 4, 112128, 9, 3);
                        // Left old code in case I did the math wrong...
                        //map.SetTile(10, 5, 128, 8032, 9, 3);
                        //map.SetTile(10, 4, 128, 8000, 9, 3);
                        map.SetAttribute(10, 6, Enums.TileType.Scripted, 46, 0, 0, "16", "683", "9:16");
                        Messenger.SendTile(10, 4, map);
                        Messenger.SendTile(10, 5, map);
                        Messenger.SendTile(10, 6, map);
                    }
                    break;
                case 19: {//daniel's fireplace question
                        if (client.Player.GetActiveRecruit().HasMove(452)) {
                            Messenger.AskQuestion(client, "Fireplace", "Will you use Rock Smash on the fireplace?", -1);
                        }
                    }
                    break;
                case 20: {//go into abandoned mansion
                        Messenger.AskQuestion(client, "AbandonedMansion2", "Only the team leader may enter this dungeon, is that OK?", -1);

                    }
                    break;
                case 21: {//vs. gengar
                        IMap map = client.Player.Map;
                        if (map.MapType != Enums.MapType.Instanced) {
                            client.CloseConnection();
                            return;
                        }
                        map.SetNpcSpawnPoint(1, 11, 6);
                        map.SetNpcSpawnPoint(2, 12, 8);
                        map.SetNpcSpawnPoint(3, 14, 8);
                        map.SetNpc(1, 804);
                        map.SetNpc(2, 809);
                        map.SetNpc(3, 812);
                        //map.SpawnNpc(1);
                        //map.SpawnNpc(2);
                        //map.SpawnNpc(3);

                    }
                    break;
                case 22: {//vs. Rotom
                        IMap map = client.Player.Map;

                        if (map.Name == "West Wing End") {
                            InstancedMap mapa = new InstancedMap(MapManager.GenerateMapID("i"));
                            MapCloner.CloneMapTiles(MapManager.RetrieveMap(825), mapa);
                            Messenger.PlayerWarp(client, mapa, 9, 10);
                            mapa.SetNpcSpawnPoint(1, 9, 3);
                            mapa.SetNpc(1, 806);
                            //mapa.SpawnNpc(1);

                        } else if (map.Name == "East Wing End") {

                            InstancedMap mapa = new InstancedMap(MapManager.GenerateMapID("i"));
                            MapCloner.CloneMapTiles(MapManager.RetrieveMap(826), mapa);
                            Messenger.PlayerWarp(client, mapa, 10, 10);
                            mapa.SetNpcSpawnPoint(1, 10, 3);
                            mapa.SetNpc(1, 807);
                            //mapa.SpawnNpc(1);

                        }
                    }
                    break;
                case 23: {//go into Hallowed Well
                        Messenger.AskQuestion(client, "HallowedWell2", "Only the team leader may enter this dungeon, and no Pokémon may be recruited.  Is that OK?", -1);
                    }
                    break;
                case 24: {//spiritomb battle
                        client.Player.TakeItem(251, 1);
                        IMap map = client.Player.Map;
                        map.SetNpcSpawnPoint(1, 9, 8);
                        map.SetNpc(1, 805);
                        //map.SpawnNpc(1);
                    }
                    break;
                case 25: {//spiritomb joins
                        // Fixed, uncomment when needed
                        // TODO: Spritomb joins
                        //client.Player.AddToRecruitmentBank(37, 209, 40, (ulong)1, 1, 0, 0, 40, 55, 10, 40, 1, 805, "Spiritomb");
                        Messenger.PlaySoundToMap(client.Player.MapID, "JoinGame.wav");
                    }
                    break;
                case 26: {//learn wish
                        client.Player.GetActiveRecruit().LearnNewMove(268);
                    }
                    break;
                case 27: {//vs. Articuno*
                        IMap map = client.Player.Map;
                        map.SetNpc(1, 440);
                        map.SetNpcSpawnPoint(1, 12, 11);
                        //map.SpawnNpc(1);
                    }
                    break;
                case 28: {//Give Natural Gift
                        Messenger.PlayerMsg(client, "You were given a Natural Gift!", Text.Yellow);
                        client.Player.GiveItem(232, 1);
                    }
                    break;
                case 29: {//Give Holly Present
                        Messenger.PlayerMsg(client, "You were given a Holly Present!", Text.Yellow);
                        client.Player.GiveItem(233, 1);
                    }
                    break;
                case 30: {//Give Mystery Gift
                        Messenger.PlayerMsg(client, "You were given a Mystery Gift!", Text.Yellow);
                        client.Player.GiveItem(234, 1);
                    }
                    break;
                case 31: {//Give PMDCP Present
                        Messenger.PlayerMsg(client, "You were given a PMDCP Present!", Text.Yellow);
                        client.Player.GiveItem(231, 1);
                    }
                    break;
                case 32: {//take white herb
                        Messenger.PlayerMsg(client, "You gave away some Candy Canes.", Text.Yellow);
                        client.Player.TakeItem(212, 12);
                    }
                    break;
                case 33: {//take soft string
                        Messenger.PlayerMsg(client, "You gave away some Soft String.", Text.Yellow);
                        client.Player.TakeItem(208, 20);
                    }
                    break;
                case 34: {//take soft snow
                        Messenger.PlayerMsg(client, "You gave away some Soft Snow.", Text.Yellow);
                        client.Player.TakeItem(209, 50);
                    }
                    break;
                case 35: {//Take ornaments
                        client.Player.GiveItem(174, 1);
                        Messenger.PlayerMsg(client, "You obtained a Shell Bell!", Text.Yellow);
                    }
                    break;
                case 36: {//vs. Heatran
                        IMap map = client.Player.Map;
                        map.SetNpc(1, 404);
                        map.SetNpcSpawnPoint(1, 12, 11);
                        //map.SpawnNpc(1);
                    }
                    break;
                case 37: {//vs. Xatu
                        BossBattles.RunPostIntroStoryBossBattle(client, "Pitch-Black Pit");
                    }
                    break;
                case 38: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "TinyGrotto");
                    }
                    break;
                case 39: {

                    BossBattles.RunBossBattleCleanup(client, client.Player.Map.Name);
                    }
                    break;
                case 40: {
                        client.Player.GiveItem(779, 1, "");
                    }
                    break;
                case 41: { // Post intro boss battle for Seaside Cavern
                        BossBattles.RunPostIntroStoryBossBattle(client, "SeasideCavern");
                    }
                    break;
                case 42: { // enter dungeon (random)

                        DungeonRules.StartRDungeon(client, param1, param2, param3);
                    }
                    break;
                case 43: {
                        BossBattles.StartBossWave(client, "ElectrostasisTowerA1", 1);
                    }
                    break;
                case 44: {
                        BossBattles.RunBossBattleCleanup(client, "ElectrostasisTowerA1");
                    }
                    break;
                case 45: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "ElectrostasisTowerA2");
                    }
                    break;
                case 46: {
                        //battle fossil & battle egg
                        int npcNum = -1;
                        switch (param1.ToInt()) {
                            case 138: //omanyte
                                npcNum = 272;
                            break;
                            case 140: //kabuto
                                npcNum = 250;
                            break;
                            case 142: //aerodactyl
                                npcNum = 132;
                            break;
                            case 345: //lileep
                                npcNum = 956;
                            break;
                            case 347: //anorith
                                npcNum = 957;
                            break;
                            case 408: //cranidos
                                npcNum = 959;
                            break;
                            case 410: //shieldon
                                npcNum = 958;
                            break;
                            case 566: //archen
                                npcNum = 973;
                            break;
                            break;
                            //case 566: //tirtouga
                            //	npcNum = 979;
                            //break;
                        }
                        if (npcNum > 0) {

                            MapNpcPreset npc = new MapNpcPreset();
                            npc.SpawnX = 9;
                            npc.SpawnY = 3;
                            npc.NpcNum = npcNum;
                            npc.MinLevel = param2.ToInt();
                            npc.MaxLevel = param2.ToInt();
                            client.Player.Map.SpawnNpc(npc);
                        }
                    }
                    break;
                case 47: {//egg hatch
                        int item = -1;
                        string[] recruitArgs = null;
                        for (int i = 1; i <= client.Player.MaxInv; i++) {
                            if (client.Player.Inventory[i].Num == 131) {
                                string[] eggArgs = client.Player.Inventory[i].Tag.Split(';');
                                if (eggArgs.Length <= 1 || !eggArgs[1].IsNumeric()) {
                                    client.Player.TakeItemSlot(i, 1, true);
                                } else {
                                    int step = eggArgs[1].ToInt();
                                    if (step <= 1) {
                                        item = i;
                                        recruitArgs = eggArgs[0].Split(',');
                                    }
                                    break;
                                }
                            }
                        }

                        if (item != -1) {

                            Recruit recruit = new Recruit(client);
                            //recruit.SpriteOverride = -1;
                            recruit.Level = 1;
                            recruit.Species = recruitArgs[0].ToInt();
                            recruit.Sex = Pokedex.GetPokemonForm(recruitArgs[0].ToInt()).GenerateLegalSex();
                            recruit.Name = Pokedex.GetPokemon(recruitArgs[0].ToInt()).Name;
                            recruit.NpcBase = 0;

                            recruit.GenerateMoveset();

                            //for egg moves, where applicable
                            List<int> eggMoves = GenerateEggMoveset(recruit.Species, recruit.Form, -1);

                            for (int i = 0; i < 4; i++) {
                                if (eggMoves.Count > 0) {
                                    int moveNum = eggMoves[Server.Math.Rand(0, eggMoves.Count)];
                                    recruit.Moves[i] = new RecruitMove();
                                    recruit.Moves[i].MoveNum = moveNum;
                                    recruit.Moves[i].MaxPP = Server.Moves.MoveManager.Moves[moveNum].MaxPP;
                                    recruit.Moves[i].CurrentPP = recruit.Moves[i].MaxPP;
                                    eggMoves.Remove(moveNum);
                                }
                            }

                            for (int i = 0; i < 4; i++) {
                                if (eggMoves.Contains(client.Player.GetActiveRecruit().Moves[i].MoveNum)) {
                                    int moveNum = client.Player.GetActiveRecruit().Moves[i].MoveNum;
                                    recruit.Moves[i] = new RecruitMove();
                                    recruit.Moves[i].MoveNum = moveNum;
                                    recruit.Moves[i].MaxPP = Server.Moves.MoveManager.Moves[moveNum].MaxPP;
                                    recruit.Moves[i].CurrentPP = recruit.Moves[i].MaxPP;
                                    eggMoves.Remove(client.Player.GetActiveRecruit().Moves[i].MoveNum);
                                }
                            }

                            int openSlot = client.Player.FindOpenTeamSlot();
                            int recruitIndex = -1;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                                recruitIndex = client.Player.AddToRecruitmentBank(dbConnection, recruit);
                            }

                            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);
                            }

                            client.Player.TakeItemSlot(item, 1, true);

                            if (recruitArgs.Length > 1) client.Player.GiveItem(recruitArgs[1].ToInt(), 1);

                        }

                    }
                    break;
                case 48: {//teach egg move

                        int species = client.Player.GetActiveRecruit().Species;

                        if (Server.Evolutions.EvolutionManager.FindPreEvolution(species) > -1) {
                            species = Server.Evolutions.EvolutionManager.FindPreEvolution(species);
                        }
                        if (Server.Evolutions.EvolutionManager.FindPreEvolution(species) > -1) {
                            species = Server.Evolutions.EvolutionManager.FindPreEvolution(species);
                        }

                        List<int> eggMoves = GenerateEggMoveset(species, client.Player.GetActiveRecruit().Form, -1);

                        Messenger.PlayerMsg(client, "Poof!", Text.BrightGreen);
                        Messenger.PlaySound(client, "magic22.wav");
                        Messenger.SpellAnim(504, client.Player.MapID, client.Player.X, client.Player.Y);
                        if (eggMoves.Count > 0) {
                            client.Player.GetActiveRecruit().LearnNewMove(eggMoves[Server.Math.Rand(0, eggMoves.Count)]);
                            Messenger.SendPlayerMoves(client);
                        } else {
                            Messenger.PlayerMsg(client, "But nothing happened...", Text.Grey);
                        }

                    }
                    break;
                case 49: {//take egg

                        int item = -1;
                        string[] recruitArgs = null;
                        for (int i = 1; i <= client.Player.MaxInv; i++) {
                            if (client.Player.Inventory[i].Num == 131) {
                                string[] eggArgs = client.Player.Inventory[i].Tag.Split(';');
                                if (eggArgs.Length <= 1 || !eggArgs[1].IsNumeric()) {
                                    client.Player.TakeItemSlot(i, 1, true);
                                } else {
                                    int step = eggArgs[1].ToInt();
                                    if (step <= 1) {
                                        item = i;
                                        recruitArgs = eggArgs[0].Split(',');
                                    }
                                    break;
                                }
                            }
                        }

                        if (item != -1) {
                            client.Player.TakeItemSlot(item, 1, true);
                        }

                    }
                    break;
                case 50: {
                        BossBattles.StartBossWave(client, "ElectrostasisTowerA1", 2);
                    }
                    break;
                case 51: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "CliffsideRelic");
                    }
                    break;
                case 52: {//enter dungeon (normal map)
                        DungeonRules.StartDungeon(client, param1, param2, param3);
                    }
                    break;
                case 53: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "ThunderstormForest");
                    }
                    break;
                case 54: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "ThunderstormForestPart2");
                    }
                    break;
                case 55: { // Open tournament listing
                        Messenger.SendTournamentListingTo(client, null);
                    }
                    break;
                case 56: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "SourRootMini");
                    }
                    break;
                case 57: {//start boss battle
                        BossBattles.PrepareBossRoom(client, (InstancedMap)client.Player.Map);
                    }
                    break;
                case 58: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "SourRoot");
                    }
                    break;
                case 59: {//run post intro story boss battle

                        BossBattles.RunPostIntroStoryBossBattle(client, param1);
                    }
                    break;
                case 60: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "SaunaCavernMini");
                    }
                    break;
                case 61: {//enter arena
                        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) {
                                    int slot = i;
                                    int amount = client.Player.Inventory[slot].Amount;
                                    int X = client.Player.Inventory[slot].Num;
                                    string tag = client.Player.Inventory[slot].Tag;
                                    int j = client.Player.FindBankSlot(X, amount);
                                    if (j == -1) {
                                        Messenger.PlayerMsg(client, "The storage can't store all items!", Text.BrightRed);
                                        return;
                                    }

                                    client.Player.TakeItemSlot(slot, amount, true);
                                    client.Player.GiveBankItem(X, amount, tag, j);

                                }
                            }
                        }
                        Messenger.PlayerMsg(client, "Items were sent to storage!", Text.Yellow);
                        EnterArena(client, client.Player.GetActiveRecruit(), client.Player.Map, param2, param3, null);
                    }
                    break;
                case 62: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "SaunaCavern");
                    }
                    break;
                case 64: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "CrystalRuins");
                    }
                    break;
                case 66: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "FrozenCitadel");
                    }
                    break;
                case 68: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "SouthernSea");
                    }
                    break;
                case 69: {
                        BossBattles.RunPostIntroStoryBossBattle(client, "LenilePit");
                    }
                    break;
                case 70: {
                        Messenger.PlayerWarp(client, 1035, 9, 7);
                    }
                    break;
                case 71: {//teach tutor move
                        int species = client.Player.GetActiveRecruit().Species;

                        List<int> eggMoves = GenerateTutorMoveset(species, client.Player.GetActiveRecruit().Form, param1.ToInt());

                        Messenger.PlayerMsg(client, "GOOOOONG!", Text.BrightGreen);
                        Messenger.PlaySound(client, "magic1011.wav");
                        Messenger.SpellAnim(498, client.Player.MapID, client.Player.X, client.Player.Y);
                        if (eggMoves.Count > 0) {
                            client.Player.GetActiveRecruit().LearnNewMove(eggMoves[Server.Math.Rand(0, eggMoves.Count)]);
                            Messenger.SendPlayerMoves(client);
                        } else {
                            Messenger.PlayerMsg(client, "But nothing happened...", Text.Grey);
                        }
                    }
                    break;

               }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: StoryScript " + scriptNum + ": " + param1 + "-" + param2 + "-" + param3, Text.Black);

                Messenger.AdminMsg(ex.ToString(), Text.Black);
            }
        }
Beispiel #11
0
        public static void BeforeRecruitLeaderChanged(Client client, Recruit currentLeader, Recruit newLeader)
        {
            try {

            } catch (Exception ex) {
                Messenger.AdminMsg("Error: BeforeRecruitLeaderChanged", Text.Black);
            }
        }
Beispiel #12
0
        public static void OnEvoDone(Client client, int script, int data1, int data2, int data3)
        {
            try {
                switch (script) {
                    case 2: {//Item
                            client.Player.TakeItem(data1, 1);
                            Messenger.PlayerMsg(client, "The item disappeared", Text.Black);
                        }
                        break;
                    case 5: {//Shedinja
                            Recruit recruit = new Recruit(client);
                            //recruit.SpriteOverride = -1;
                            recruit.Level = client.Player.GetActiveRecruit().Level;
                            recruit.Species = 292;
                            recruit.PermanentForm = 0;
                            recruit.Form = 0;
                            recruit.Sex = Enums.Sex.Genderless;
                            recruit.Name = Pokedex.GetPokemon(292).Name;
                            recruit.NpcBase = 0;

                            for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                                recruit.Moves[i] = client.Player.GetActiveRecruit().Moves[i];
                            }

                            int openSlot = client.Player.FindOpenTeamSlot();
                            int recruitIndex = -1;
                            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                                recruitIndex = client.Player.AddToRecruitmentBank(dbConnection, recruit);
                            }

                            if (recruitIndex != -1) {
                                client.Player.AddToTeam(recruitIndex, openSlot);
                                client.Player.Team[openSlot].HP = client.Player.Team[openSlot].MaxHP;
                                Messenger.PlayerMsg(client, "Oh?  A new team member...?", Text.Black);
                                Messenger.SendActiveTeam(client);
                            }
                        }
                        break;
                }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: OnEvoDone", Text.Black);
            }
        }
Beispiel #13
0
        public void UseMoveOnFoes(BattleSetup setup, TargetCollection targets)
        {
            Parties.Party party = null;
            if (owner.Player.IsInParty())
            {
                party = Parties.PartyManager.FindPlayerParty(owner);
            }

            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, owner.Player.X, owner.Player.Y, owner.Player.Direction);

            Move move = setup.SetdownMove();

            foreach (ICharacter i in targets.Foes)
            {
                // Don't attack allies
                if (i.CharacterType == Enums.CharacterType.Recruit)
                {
                    Recruit recruit = i as Recruit;

                    var canHit = true;

                    if (Ranks.IsAllowed(recruit.Owner, Enums.Rank.Monitor) && !recruit.Owner.Player.Hunted)
                    {
                        canHit = false;
                    }

                    if ((recruit.Owner.Player.Map.Tile[recruit.Owner.Player.X, recruit.Owner.Player.Y].Type == Enums.TileType.Arena) != (Owner.Player.Map.Tile[X, Y].Type == Enums.TileType.Arena))
                    {
                        canHit = false;
                    }

                    // Override to allow hitting the player ANYWHERE
                    if (recruit.Owner.Player.KillableAnywhere)
                    {
                        canHit = true;
                    }

                    if (canHit)
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc && (((MapNpc)i).Num <= 0 || ((MapNpc)i).HP <= 0))
                {
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc)
                {
                    MapNpc npc = i as MapNpc;
                    if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Scripted)
                    {
                        if (setup.moveIndex == -1)
                        {
                            Scripting.ScriptManager.InvokeSub("ScriptedNpc", setup.Attacker, Npcs.NpcManager.Npcs[npc.Num].AIScript, npc.Num, owner.Player.Map, i);
                        }
                    }
                    else if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Story)
                    {
                        if (setup.moveIndex == -1)
                        {
                            var npcObject = Npcs.NpcManager.Npcs[npc.Num];

                            var storyChapter = npcObject.Story - 1;
                            if (storyChapter <= -1 || owner.Player.GetStoryState(storyChapter))
                            {
                                Stories.StoryManager.PlayStory(owner, Npcs.NpcManager.Npcs[npc.Num].CreateAttackSayStory());
                            }
                            else
                            {
                                if (owner.Player.GetClientEdition() == Constants.ALTERNATE_CLIENT_EDITION)
                                {
                                    Stories.StoryManager.PlayStory(owner, storyChapter);
                                }
                                else
                                {
                                    Stories.StoryManager.PlayStory(owner, Npcs.NpcManager.Npcs[npc.Num].CreateInvalidClientStory());
                                }
                            }
                        }
                    }
                    else if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Shopkeeper && Npcs.NpcManager.Npcs[npc.Num].Shop > 0)
                    {
                        if (setup.moveIndex == -1)
                        {
                            Messenger.SendShopMenu(owner, Npcs.NpcManager.Npcs[npc.Num].Shop);
                        }
                    }
                    else if (!string.IsNullOrEmpty(Npcs.NpcManager.Npcs[npc.Num].AttackSay) && (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Friendly || Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Shopkeeper))
                    {
                        if (setup.moveIndex == -1)
                        {
                            var story = Npcs.NpcManager.Npcs[npc.Num].CreateAttackSayStory();

                            Stories.StoryManager.PlayStory(owner, story);
                        }
                    }
                    else
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel)
                    {
                        return;
                    }
                }
            }
        }
Beispiel #14
0
        public void UseMoveOnFoes(BattleSetup setup, TargetCollection targets)
        {
            Parties.Party party = null;
            if (owner.Player.IsInParty())
            {
                party = Parties.PartyManager.FindPlayerParty(owner);
            }

            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, owner.Player.X, owner.Player.Y, owner.Player.Direction);

            Move move = setup.SetdownMove();

            foreach (ICharacter i in targets.Foes)
            {
                // Don't attack allies
                if (i.CharacterType == Enums.CharacterType.Recruit)
                {
                    Recruit recruit = i as Recruit;
                    if (Ranks.IsAllowed(recruit.Owner, Enums.Rank.Moniter) && !recruit.Owner.Player.Hunted ||
                        (recruit.Owner.Player.Map.Tile[recruit.Owner.Player.X, recruit.Owner.Player.Y].Type == Enums.TileType.Arena) != (Owner.Player.Map.Tile[X, Y].Type == Enums.TileType.Arena))
                    {
                    }
                    else
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc && (((MapNpc)i).Num <= 0 || ((MapNpc)i).HP <= 0))
                {
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc)
                {
                    MapNpc npc = i as MapNpc;
                    if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Scripted)
                    {
                        if (setup.moveIndex == -1)
                        {
                            Scripting.ScriptManager.InvokeSub("ScriptedNpc", setup.Attacker, Npcs.NpcManager.Npcs[npc.Num].AIScript, npc.Num, owner.Player.Map, i);
                        }
                    }
                    else if (!string.IsNullOrEmpty(Npcs.NpcManager.Npcs[npc.Num].AttackSay) && (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Friendly || Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Shopkeeper))
                    {
                        if (setup.moveIndex == -1)
                        {
                            Stories.Story story = new Stories.Story();
                            Stories.StoryBuilderSegment segment = Stories.StoryBuilder.BuildStory();
                            Stories.StoryBuilder.AppendSaySegment(segment, Npcs.NpcManager.Npcs[npc.Num].Name.Trim() + ": " + Npcs.NpcManager.Npcs[npc.Num].AttackSay.Trim(),
                                                                  Npcs.NpcManager.Npcs[npc.Num].Species, 0, 0);
                            segment.AppendToStory(story);
                            Stories.StoryManager.PlayStory(owner, story);
                        }
                    }
                    else
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel)
                    {
                        return;
                    }
                }
            }
        }