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++; }
/// <summary> /// Processes the commands for generating world /// </summary> /// <param name="drlgParams"></param> /// <param name="worldData"></param> /// <param name="levelIndex"></param> private static void ProcessCommands(DRLGParams drlgParams, Mooege.Common.MPQ.FileFormats.World worldData, int levelIndex) { //Process commands foreach (var command in drlgParams.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[levelIndex] = 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 TileType //foreach (var tile in worldTiles) //{ //} } } }
private static bool GenerateRandomDungeon(int worldSNO, Mooege.Common.MPQ.FileFormats.World worldData) { if (worldData.DRLGParams.Count == 0) { return(false); } 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; return(true); }