Example #1
0
        private static void AddTile(Mooege.Common.MPQ.FileFormats.World worldData, TileInfo tileInfo, Vector3D location)
        {
            var sceneChunk = new SceneChunk();
            sceneChunk.SNOHandle = new SNOHandle(tileInfo.SNOScene);
            sceneChunk.PRTransform = new PRTransform();
            sceneChunk.PRTransform.Quaternion = new Quaternion();
            sceneChunk.PRTransform.Quaternion.W = 1.0f;
            sceneChunk.PRTransform.Quaternion.Vector3D = new Vector3D(0, 0, 0);
            sceneChunk.PRTransform.Vector3D = new Vector3D();
            sceneChunk.PRTransform.Vector3D = location;

            var spec = new SceneSpecification();
            //scene.Specification = spec;
            spec.Cell = new Vector2D() { X = 0, Y = 0 };
            spec.CellZ = 0;
            spec.SNOLevelAreas = new int[] { -1, -1, -1, -1 };
            spec.SNOMusic = -1;
            spec.SNONextLevelArea = -1;
            spec.SNONextWorld = -1;
            spec.SNOPresetWorld = -1;
            spec.SNOPrevLevelArea = -1;
            spec.SNOPrevWorld = -1;
            spec.SNOReverb = -1;
            spec.SNOWeather = 50542;
            spec.SNOCombatMusic = -1;
            spec.SNOAmbient = -1;
            spec.ClusterID = -1;
            spec.Unknown1 = 14;
            spec.Unknown3 = 5;
            spec.Unknown4 = -1;
            spec.Unknown5 = 0;
            spec.SceneCachedValues = new SceneCachedValues();
            spec.SceneCachedValues.Unknown1 = 63;
            spec.SceneCachedValues.Unknown2 = 96;
            spec.SceneCachedValues.Unknown3 = 96;
            var sceneFile = MPQStorage.Data.Assets[SNOGroup.Scene][tileInfo.SNOScene];
            var sceneData = (Mooege.Common.MPQ.FileFormats.Scene)sceneFile.Data;
            spec.SceneCachedValues.AABB1 = sceneData.AABBBounds;
            spec.SceneCachedValues.AABB2 = sceneData.AABBMarketSetBounds;
            spec.SceneCachedValues.Unknown4 = new int[4] { 0, 0, 0, 0 };

            sceneChunk.SceneSpecification = spec;

            worldData.SceneParams.SceneChunks.Add(sceneChunk);
            worldData.SceneParams.ChunkCount++;
        }
Example #2
0
        /// <summary>
        /// Adds tiles to all exits of a tile
        /// </summary>
        /// <param name="worldTiles">Contains a list of already added tiles.</param>
        /// <param name="tileInfo">Originating tile</param>
        /// <param name="tiles">List of tiles to choose from</param>
        /// <param name="counter">Contains how many tiles were added. When counter reached it will look for an exit.
        /// If exit was not found look for deadend(filler?). </param>
        /// <param name="position">Position of originating tile.</param>
        /// <param name="x">Originating tile world x position</param>
        private static int AddAdjacentTiles(Dictionary<Vector3D, TileInfo> worldTiles, TileInfo tileInfo, Dictionary<int, TileInfo> tiles, int counter, Vector3D position)
        {
            Logger.Debug("Counter: {0}, ExitDirectionbitsOfGivenTile: {1}", counter, tileInfo.ExitDirectionBits);
            var lookUpExits = GetLookUpExitBits(tileInfo.ExitDirectionBits);

            Dictionary<TileExits, Vector3D> randomizedExitTypes = GetAdjacentPositions(position, true);

            //add adjacent tiles for each randomized direction
            foreach (var exit in randomizedExitTypes)
            {
                if ((lookUpExits & (int)exit.Key) > 0 && !worldTiles.ContainsKey(exit.Value))
                {
                    counter = AddadjacentTileAtExit(worldTiles, tiles, counter, exit.Value);
                }
            }

            return counter;
        }
Example #3
0
        /// <summary>
        /// Adds tiles to all exits of a tile
        /// </summary>
        /// <param name="worldTiles">Contains a list of already added tiles.</param>
        /// <param name="tileInfo">Originating tile</param>
        /// <param name="tiles">List of tiles to choose from</param>
        /// <param name="counter">Contains how many tiles were added. When counter reached it will look for an exit. 
        /// If exit was not found look for deadend(filler?). </param>
        /// <param name="position">Position of originating tile.</param>
        /// <param name="x">Originating tile world x position</param>
        private static int AddadjacentTiles(Dictionary<Vector3D, TileInfo> worldTiles, TileInfo tileInfo, Dictionary<int, TileInfo> tiles, int counter, Vector3D position)
        {
            Logger.Debug("Counter: {0}, ExitDirectionbitsOfGivenTile: {1}", counter, tileInfo.ExitDirectionBits);
            var lookUpExits = GetLookUpExitBits(tileInfo.ExitDirectionBits);
            Vector3D positionEast = new Vector3D(position.X - 240, position.Y, 0);
            Vector3D positionWest = new Vector3D(position.X + 240, position.Y, 0);
            Vector3D positionNorth = new Vector3D(position.X, position.Y - 240, 0);
            Vector3D positionSouth = new Vector3D(position.X, position.Y + 240, 0);

            //get a random direction
            Dictionary<TileExits, Vector3D> exitTypes = new Dictionary<TileExits, Vector3D>();
            exitTypes.Add(TileExits.East, positionEast);
            exitTypes.Add(TileExits.West, positionWest);
            exitTypes.Add(TileExits.North, positionNorth);
            exitTypes.Add(TileExits.South, positionSouth);

            Dictionary<TileExits, Vector3D> randomizedExitTypes = new Dictionary<TileExits, Vector3D>();
            var count = exitTypes.Count;

            //Randomise exit directions
            for (int i = 0; i < count; i++)
            {
                //Chose a random exit to test
                Vector3D chosenExitPosition = RandomHelper.RandomValue(exitTypes);
                var chosenExitDirection = (from pair in exitTypes
                                           where pair.Value == chosenExitPosition
                                           select pair.Key).FirstOrDefault();
                randomizedExitTypes.Add(chosenExitDirection, chosenExitPosition);
                exitTypes.Remove(chosenExitDirection);
            }

            //add adjacent tiles for each randomized direction
            foreach (var exit in randomizedExitTypes)
            {
                if ((lookUpExits & (int)exit.Key) > 0 && !worldTiles.ContainsKey(exit.Value))
                {
                    counter = AddadjacentTileAtExit(worldTiles, tiles, counter, exit.Value);
                }
            }

            return counter;
        }
Example #4
0
        private static void GenerateRandomDungeon(int worldSNO, Mooege.Common.MPQ.FileFormats.World worldData)
        {
            Dictionary<int, TileInfo> tiles = new Dictionary<int, TileInfo>();

            //Each DRLGParam is a level
            for (int paramIndex = 0; paramIndex < worldData.DRLGParams.Count; paramIndex++)
            {
                var drlgparam = worldData.DRLGParams[paramIndex];
                foreach (var tile in drlgparam.Tiles)
                {
                    Logger.Debug("RandomGeneration: TileType: {0}", (TileTypes)tile.TileType);
                    tiles.Add(tile.SNOScene, tile);
                }

                TileInfo entrance = new TileInfo();
                //HACK for Defiled Crypt as there is no tile yet with type 200. Maybe changing in DB would make more sense than putting this hack in
                //    [11]: {[161961, Mooege.Common.MPQ.MPQAsset]}Worlds\\a1trDun_Cave_Old_Ruins_Random01.wrl
                if (worldSNO == 161961)
                {
                    entrance = tiles[131902];
                    tiles.Remove(131902);
                }
                else
                    entrance = GetTileInfo(tiles, TileTypes.Entrance);

                Vector3D initialStartTilePosition = new Vector3D(480, 480, 0);
                Dictionary<Vector3D, TileInfo> worldTiles = new Dictionary<Vector3D, TileInfo>();
                worldTiles.Add(initialStartTilePosition, entrance);
                AddAdjacentTiles(worldTiles, entrance, tiles, 0, initialStartTilePosition);
                AddFillers(worldTiles, tiles);

                foreach (var tile in worldTiles)
                {
                    AddTile(worldData, tile.Value, tile.Key);
                }

                //AddFiller
                ProcessCommands(drlgparam, worldData, paramIndex);
            }
            //Coordinates are added after selection of tiles and map
            //Leave it for Defiler Crypt debugging
            //AddTile(world, tiles[132218], new Vector3D(720, 480, 0));
            //AddTile(world, tiles[132203], new Vector3D(480, 240, 0));
            //AddTile(world, tiles[132263], new Vector3D(240, 480, 0));
            //return world;
        }
Example #5
0
        private static void GenerateRandomDungeon(int worldSNO, Mooege.Common.MPQ.FileFormats.World worldData)
        {
            Dictionary<int, TileInfo> tiles = new Dictionary<int, TileInfo>();

            //Each DRLGParam is a level
            for (int paramIndex = 0; paramIndex < worldData.DRLGParams.Count; paramIndex++)
            {
                var drlgparam = worldData.DRLGParams[paramIndex];
                foreach (var tile in drlgparam.Tiles)
                {
                    Logger.Debug("RandomGeneration: TileType: {0}", (TileTypes)tile.TileType);
                    tiles.Add(tile.SNOScene, tile);
                }

                TileInfo entrance = new TileInfo();
                //HACK for Defiled Crypt as there is no tile yet with type 200. Maybe changing in DB would make more sense than putting this hack in
                //    [11]: {[161961, Mooege.Common.MPQ.MPQAsset]}Worlds\\a1trDun_Cave_Old_Ruins_Random01.wrl
                if (worldSNO == 161961)
                {
                    entrance = tiles[131902];
                    tiles.Remove(131902);
                }
                else
                    entrance = GetTileInfo(tiles, TileTypes.Entrance);

                Vector3D initialStartTilePosition = new Vector3D(480, 480, 0);
                Dictionary<Vector3D, TileInfo> worldTiles = new Dictionary<Vector3D, TileInfo>();
                worldTiles.Add(initialStartTilePosition, entrance);
                AddadjacentTiles(worldTiles, entrance, tiles, 0, initialStartTilePosition);

                foreach (var tile in worldTiles)
                {
                    AddTile(worldData, tile.Value, tile.Key);
                }

                //Process commands
                foreach (var command in drlgparam.Commands)
                {
                    //Adds information about level
                    if (command.CommandType == (int)CommandType.Group)
                    {
                        //  command.TagMap
                        //{Mooege.Core.GS.Common.Types.TagMap.TagMap}
                        //    _tagMapEntries: Count = 6
                        //    TagMapEntries: Count = 6
                        //    TagMapSize: 0
                        //command.TagMap.TagMapEntries
                        //Count = 6
                        //    [0]: {851986 = -1}
                        //    [1]: {1015841 = 1}
                        //    [2]: {851987 = -1}
                        //    [3]: {851993 = -1}
                        //    [4]: {1015822 = 0}
                        //    [5]: {851983 = 19780} //19780 LevelArea A1_trDun_Level01
                        //hardcode this now until proper tagmap implementation is done
                        foreach (var chunk in worldData.SceneParams.SceneChunks)
                        {
                            if (command.TagMap.ContainsKey(DRLGCommandKeys.Group.Level))
                                chunk.SceneSpecification.SNOLevelAreas[paramIndex] = command.TagMap[DRLGCommandKeys.Group.Level].Id;
                        }


                    }
                    if (command.CommandType == (int)CommandType.AddExit)
                    {
                        //drlgparam.Commands[6].TagMap.TagMapEntries
                        //[0]: {852000 = -1}    Type SNO (2)
                        //[1]: {851984 = 60713} Type SNO (2) [20:16] (snobot) [1] 60713 Worlds trDun_Cain_Intro, 
                        //[2]: {1020032 = 1}    (0)
                        //[3]: {852050 = 0}     //Starting location? ID (7)
                        //[4]: {1015841 = 1}    (0)
                        //[5]: {852051 = 172}   //Destination Actor Tag (7)
                        //[6]: {1015814 = 0}    (0)
                        //[7]: {854612 = -1}    Type SNO (2)
                        //[8]: {1015813 = 300}  (0) Tiletype (exit)
                        //[9]: {1020416 = 1}    (0)
                        //[10]: {854613 = -1}   Type SNO (2)
                        //[11]: {1015821 = -1}  (0)

                        //find all tiles of type
                        //foreach(tiles.
                        foreach (var tile in worldTiles)
                        {
                        }
                    }
                }

            }
            //Coordinates are added after selection of tiles and map
            //Leave it for Defiler Crypt debugging
            //AddTile(world, tiles[132218], new Vector3D(720, 480, 0));
            //AddTile(world, tiles[132203], new Vector3D(480, 240, 0));
            //AddTile(world, tiles[132263], new Vector3D(240, 480, 0));
            //return world;
        }