Exemplo n.º 1
0
 public static void Packet_SaveHouses(int index, ref byte[] data)
 {
     checked
     {
         if (!(S_Players.GetPlayerAccess(index) < 2))
         {
             ByteStream buffer = new ByteStream(data);
             int        Count  = buffer.ReadInt32();
             if (Count > 0)
             {
                 int num = Count;
                 for (int z = 1; z <= num; z++)
                 {
                     int i = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].ConfigName   = (buffer.ReadString().Trim());
                     S_Housing.HouseConfig[i].BaseMap      = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].X            = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].Y            = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].Price        = buffer.ReadInt32();
                     S_Housing.HouseConfig[i].MaxFurniture = buffer.ReadInt32();
                     S_Housing.SaveHouse(i);
                     int playersOnline = S_GameLogic.GetPlayersOnline();
                     for (int x = 1; x <= playersOnline; x++)
                     {
                         if (S_NetworkConfig.IsPlaying(x) && modTypes.Player[x].Character[(int)modTypes.TempPlayer[x].CurChar].InHouse == i)
                         {
                             S_Housing.SendFurnitureToHouse(i);
                         }
                     }
                 }
             }
             buffer.Dispose();
         }
     }
 }
Exemplo n.º 2
0
 private static void LoadGameData()
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("Loading Classes..."); modDatabase.LoadClasses();
     Console.WriteLine("Loading Maps..."); modDatabase.LoadMaps();
     Console.WriteLine("Creating Map Matrices...");
     for (int i = 1; i < Constants.MAX_MAPS; i++)
     {
         modPathfinding.CreatePathMatrix(i);
     }
     Console.WriteLine("Loading Items..."); S_Items.LoadItems();
     Console.WriteLine("Loading Npc's..."); modDatabase.LoadNpcs();
     Console.WriteLine("Loading Resources..."); S_Resources.LoadResources();
     Console.WriteLine("Loading Shops..."); modDatabase.LoadShops();
     Console.WriteLine("Loading Skills..."); modDatabase.LoadSkills();
     Console.WriteLine("Loading Animations..."); S_Animations.LoadAnimations();
     Console.WriteLine("Loading Quests..."); S_Quest.LoadQuests();
     Console.WriteLine("Loading House Configurations..."); S_Housing.LoadHouses();
     Console.WriteLine("Loading Switches..."); S_Events.LoadSwitches();
     Console.WriteLine("Loading Variables..."); S_Events.LoadVariables();
     Console.WriteLine("Spawning global events..."); S_EventLogic.SpawnAllMapGlobalEvents();
     Console.WriteLine("Loading projectiles..."); S_Projectiles.LoadProjectiles();
     Console.WriteLine("Loading Recipes..."); modCrafting.LoadRecipes();
     Console.WriteLine("Loading Pets..."); S_Pets.LoadPets();
     Console.ResetColor();
 }
Exemplo n.º 3
0
        public static void SaveHouses()
        {
            int max_HOUSES = S_Housing.MAX_HOUSES;

            checked
            {
                for (int i = 1; i <= max_HOUSES; i++)
                {
                    S_Housing.SaveHouse(i);
                }
            }
        }
Exemplo n.º 4
0
 private static void LoadGameData()
 {
     Console.WriteLine("Loading Classes..."); modDatabase.LoadClasses();
     Console.WriteLine("Loading Maps..."); modDatabase.LoadMaps();
     Console.WriteLine("Loading Items..."); S_Items.LoadItems();
     Console.WriteLine("Loading Npc's..."); modDatabase.LoadNpcs();
     Console.WriteLine("Loading Resources..."); S_Resources.LoadResources();
     Console.WriteLine("Loading Shops..."); modDatabase.LoadShops();
     Console.WriteLine("Loading Skills..."); modDatabase.LoadSkills();
     Console.WriteLine("Loading Animations..."); S_Animations.LoadAnimations();
     Console.WriteLine("Loading Quests..."); S_Quest.LoadQuests();
     Console.WriteLine("Loading House Configurations..."); S_Housing.LoadHouses();
     Console.WriteLine("Loading Switches..."); S_Events.LoadSwitches();
     Console.WriteLine("Loading Variables..."); S_Events.LoadVariables();
     Console.WriteLine("Spawning global events..."); S_EventLogic.SpawnAllMapGlobalEvents();
     Console.WriteLine("Loading projectiles..."); S_Projectiles.LoadProjectiles();
     Console.WriteLine("Loading Recipes..."); modCrafting.LoadRecipes();
     Console.WriteLine("Loading Pets..."); S_Pets.LoadPets();
 }
Exemplo n.º 5
0
        public static void SaveHouse(int index)
        {
            XmlClass myXml = new XmlClass
            {
                Filename = Path.Combine(Application.StartupPath, "data", "houseconfig.xml"),
                Root     = "Config"
            };

            myXml.LoadXml();
            if (index > 0 && index <= S_Housing.MAX_HOUSES)
            {
                myXml.WriteString("House" + Conversions.ToString(index), "BaseMap", Conversions.ToString(S_Housing.HouseConfig[index].BaseMap));
                myXml.WriteString("House" + Conversions.ToString(index), "Name", S_Housing.HouseConfig[index].ConfigName);
                myXml.WriteString("House" + Conversions.ToString(index), "MaxFurniture", Conversions.ToString(S_Housing.HouseConfig[index].MaxFurniture));
                myXml.WriteString("House" + Conversions.ToString(index), "Price", Conversions.ToString(S_Housing.HouseConfig[index].Price));
                myXml.WriteString("House" + Conversions.ToString(index), "X", Conversions.ToString(S_Housing.HouseConfig[index].X));
                myXml.WriteString("House" + Conversions.ToString(index), "Y", Conversions.ToString(S_Housing.HouseConfig[index].Y));
            }
            myXml.CloseXml(true);
            S_Housing.LoadHouses();
        }
Exemplo n.º 6
0
        // Token: 0x060001D8 RID: 472 RVA: 0x000398D4 File Offset: 0x00037AD4
        public static void LoadHouses()
        {
            bool flag = !File.Exists(Path.Combine(Application.StartupPath, "data", "houseconfig.xml"));

            if (flag)
            {
                S_Housing.CreateHouses();
            }
            XmlClass myXml = new XmlClass
            {
                Filename = Path.Combine(Application.StartupPath, "data", "houseconfig.xml"),
                Root     = "Config"
            };

            myXml.LoadXml();
            int max_HOUSES = S_Housing.MAX_HOUSES;

            checked
            {
                for (int i = 1; i <= max_HOUSES; i++)
                {
                    S_Housing.HouseConfig[i].BaseMap      = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "BaseMap", "")));
                    S_Housing.HouseConfig[i].ConfigName   = (myXml.ReadString("House" + Conversions.ToString(i), "Name", "").Trim());
                    S_Housing.HouseConfig[i].MaxFurniture = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "MaxFurniture", "")));
                    S_Housing.HouseConfig[i].Price        = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "Price", "")));
                    S_Housing.HouseConfig[i].X            = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "X", "")));
                    S_Housing.HouseConfig[i].Y            = (int)Math.Round(Conversion.Val(myXml.ReadString("House" + Conversions.ToString(i), "Y", "")));
                }
                myXml.CloseXml(false);
                int playersOnline = S_GameLogic.GetPlayersOnline();
                for (int i = 1; i <= playersOnline; i++)
                {
                    bool flag2 = S_NetworkConfig.IsPlaying(i);
                    if (flag2)
                    {
                        S_Housing.SendHouseConfigs(i);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public static void Packet_PlaceFurniture(int index, ref byte[] data)
        {
            ByteStream buffer  = new ByteStream(data);
            int        x       = buffer.ReadInt32();
            int        y       = buffer.ReadInt32();
            int        invslot = buffer.ReadInt32();

            buffer.Dispose();
            int ItemNum = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].Inv[invslot].Num;

            checked
            {
                if (!(ItemNum < 1 || ItemNum > 500))
                {
                    if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse == index)
                    {
                        if (Types.Item[ItemNum].Type == 6)
                        {
                            int i = 1;
                            for (; ;)
                            {
                                if (S_Players.GetPlayerRawStat(index, (Enums.StatType)i) < (int)Types.Item[ItemNum].Stat_Req[i])
                                {
                                    break;
                                }
                                i++;
                                if (i > 6)
                                {
                                    goto Block_6;
                                }
                            }
                            S_NetworkSend.PlayerMsg(index, "You do not meet the stat requirements to use this item.", 12);
                            return;

Block_6:
                            if (S_Players.GetPlayerLevel(index) < Types.Item[ItemNum].LevelReq)
                            {
                                S_NetworkSend.PlayerMsg(index, "You do not meet the level requirement to use this item.", 12);
                            }
                            else
                            {
                                if (Types.Item[ItemNum].ClassReq > 0)
                                {
                                    if (S_Players.GetPlayerClass(index) != Types.Item[ItemNum].ClassReq)
                                    {
                                        S_NetworkSend.PlayerMsg(index, "You do not meet the class requirement to use this item.", 12);
                                        return;
                                    }
                                }
                                if (S_Players.GetPlayerAccess(index) < Types.Item[ItemNum].AccessReq)
                                {
                                    S_NetworkSend.PlayerMsg(index, "You do not meet the access requirement to use this item.", 12);
                                }
                                else
                                {
                                    if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse != index)
                                    {
                                        S_NetworkSend.PlayerMsg(index, "You must be inside your house to place furniture!", 14);
                                    }
                                    else
                                    {
                                        if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount >= S_Housing.HouseConfig[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Houseindex].MaxFurniture)
                                        {
                                            if (S_Housing.HouseConfig[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Houseindex].MaxFurniture > 0)
                                            {
                                                S_NetworkSend.PlayerMsg(index, "Your house cannot hold any more furniture!", 12);
                                                return;
                                            }
                                        }
                                        if (!(x < 0 || x > (int)modTypes.Map[S_Players.GetPlayerMap(index)].MaxX))
                                        {
                                            if (!(y < 0 || y > (int)modTypes.Map[S_Players.GetPlayerMap(index)].MaxY))
                                            {
                                                int x2;
                                                int widthoffset;
                                                if (Types.Item[ItemNum].FurnitureWidth > 2)
                                                {
                                                    x2          = (int)Math.Round(unchecked ((double)x + (double)Types.Item[ItemNum].FurnitureWidth / 2.0));
                                                    widthoffset = x2 - x;
                                                    x2         -= Types.Item[ItemNum].FurnitureWidth - widthoffset;
                                                }
                                                x2          = x;
                                                widthoffset = 0;
                                                int y2 = y;
                                                if (widthoffset > 0)
                                                {
                                                    int num  = x2;
                                                    int num2 = x2 + widthoffset;
                                                    for (x = num; x <= num2; x++)
                                                    {
                                                        int num3 = y2;
                                                        int num4 = y2 - Types.Item[ItemNum].FurnitureHeight + 1;
                                                        for (y = num3; y >= num4; y += -1)
                                                        {
                                                            if (modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Type == 1)
                                                            {
                                                                return;
                                                            }
                                                            int playersOnline = S_GameLogic.GetPlayersOnline();
                                                            for (i = 1; i <= playersOnline; i++)
                                                            {
                                                                if (S_NetworkConfig.IsPlaying(i) && i != index && S_Players.GetPlayerMap(i) == S_Players.GetPlayerMap(index))
                                                                {
                                                                    if (modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].InHouse == modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse)
                                                                    {
                                                                        if ((int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].X == x && (int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].Y == y)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount > 0)
                                                            {
                                                                int furnitureCount = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount;
                                                                for (i = 1; i <= furnitureCount; i++)
                                                                {
                                                                    if (x >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X && x <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X + Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureWidth - 1)
                                                                    {
                                                                        if (y <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y && y >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y - Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureHeight + 1)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    int num5 = x2;
                                                    int num6 = x2 - (Types.Item[ItemNum].FurnitureWidth - widthoffset);
                                                    for (x = num5; x >= num6; x += -1)
                                                    {
                                                        int num7 = y2;
                                                        int num8 = y2 - Types.Item[ItemNum].FurnitureHeight + 1;
                                                        for (y = num7; y >= num8; y += -1)
                                                        {
                                                            if (modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Type == 1)
                                                            {
                                                                return;
                                                            }
                                                            int playersOnline2 = S_GameLogic.GetPlayersOnline();
                                                            for (i = 1; i <= playersOnline2; i++)
                                                            {
                                                                if (S_NetworkConfig.IsPlaying(i) && i != index && S_Players.GetPlayerMap(i) == S_Players.GetPlayerMap(index))
                                                                {
                                                                    if (modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].InHouse == modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse)
                                                                    {
                                                                        if ((int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].X == x && (int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].Y == y)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount > 0)
                                                            {
                                                                int furnitureCount2 = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount;
                                                                for (i = 1; i <= furnitureCount2; i++)
                                                                {
                                                                    if (x >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X && x <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X + Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureWidth - 1)
                                                                    {
                                                                        if (y <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y && y >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y - Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureHeight + 1)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    int num9  = x2;
                                                    int num10 = x2 + Types.Item[ItemNum].FurnitureWidth - 1;
                                                    for (x = num9; x <= num10; x++)
                                                    {
                                                        int num11 = y2;
                                                        int num12 = y2 - Types.Item[ItemNum].FurnitureHeight + 1;
                                                        for (y = num11; y >= num12; y += -1)
                                                        {
                                                            if (modTypes.Map[S_Players.GetPlayerMap(index)].Tile[x, y].Type == 1)
                                                            {
                                                                return;
                                                            }
                                                            int playersOnline3 = S_GameLogic.GetPlayersOnline();
                                                            for (i = 1; i <= playersOnline3; i++)
                                                            {
                                                                if (S_NetworkConfig.IsPlaying(i) && i != index && S_Players.GetPlayerMap(i) == S_Players.GetPlayerMap(index))
                                                                {
                                                                    if (modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].InHouse == modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse)
                                                                    {
                                                                        if ((int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].X == x && (int)modTypes.Player[i].Character[(int)modTypes.TempPlayer[i].CurChar].Y == y)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount > 0)
                                                            {
                                                                int furnitureCount3 = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount;
                                                                for (i = 1; i <= furnitureCount3; i++)
                                                                {
                                                                    if (x >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X && x <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].X + Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureWidth - 1)
                                                                    {
                                                                        if (y <= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y && y >= modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].Y - Types.Item[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[i].ItemNum].FurnitureHeight + 1)
                                                                        {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                x = x2;
                                                y = y2;
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount = modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount + 1;
                                                modTypes.CharacterRec[] character = modTypes.Player[index].Character;
                                                byte curChar = modTypes.TempPlayer[index].CurChar;
                                                character[(int)curChar].House.Furniture = (S_Housing.FurnitureRec[])Utils.CopyArray(character[(int)curChar].House.Furniture, new S_Housing.FurnitureRec[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount + 1]);
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount].ItemNum = ItemNum;
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount].X       = x;
                                                modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Furniture[modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.FurnitureCount].Y       = y;
                                                S_Players.TakeInvItem(index, ItemNum, 0);
                                                S_Housing.SendFurnitureToHouse(modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse);
                                                modDatabase.SavePlayer(index);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        S_NetworkSend.PlayerMsg(index, "You cannot place furniture unless you are in your own house!", 12);
                    }
                }
            }
        }