Beispiel #1
0
    public static Dictionary <AssetId, object> Build(MapId mapId)
    {
        var assets  = new Dictionary <AssetId, object>();
        var builder = MapBuilder.Create2D(mapId, Palette1Id, Tileset1.Tileset.Id, MapWidth, MapHeight);

        builder.Draw2D(map =>
        {
            map.Flags |= MapFlags.Unk8000 | MapFlags.ExtraNpcs;

            Array.Fill(map.Overlay, 0);
            for (int i = 0; i < map.Underlay.Length; i++)
            {
                var y           = i / map.Width;
                var x           = i % map.Width;
                map.Underlay[i] =
                    x == 0 || y == 0 || x == map.Width - 1 || y == map.Height - 1
                        ? Tileset1.SolidOffset
                        : Tileset1.BlankOffset;
            }

            ushort n = 0;
            void Add(string name, Func <Func <string, int>, string> scriptBuilder)
            {
                for (var index = 0; index < name.Length; index++)
                {
                    var c = name[index];
                    map.Underlay[Pos(index + 1, n + 1)] = Tileset1.IndexForChar(c);
                }

                builder.SetChain(n, scriptBuilder);
                map.AddZone(1, (byte)(n + 1), TriggerTypes.Manipulate, n);
                n++;
            }

            Add("S0", s => @$ "
    text {s(" Setting switch 0 ")}
    switch 1 0
");

            Add("S!", s => @$ "
    text {s(" Setting switch 1023 ")}
    switch 1 1023
");

            Add("D0", s =>
            {
                var openText   = s("Opened door 0");
                var unlockText = s("Unlocked door 0");
                return(@$ "
    text {s(" Opening door 0 ")}
    open_door 0 {mapId.ToMapText()} Item.FragrantWater 50 {openText} {unlockText}
");
            });

            Add("D!", s =>
            {
                var openText   = s("Opened door 998");
                var unlockText = s("Unlocked door 998");
                return(@$ "
    text {s(" Opening door 998 ")}
    open_door 998 {mapId.ToMapText()} Item.FragrantWater 50 {openText} {unlockText}
");
            });
Beispiel #2
0
        static void BuildEventHash(MapId mapId, IScriptable scriptable, AssetMapping mapping)
        {
            if (scriptable.Events == null)
            {
                return;
            }

            scriptable.EventBytes = FormatUtil.SerializeToBytes(s =>
            {
                for (ushort i = 0; i < scriptable.Events.Count; i++)
                {
                    scriptable.Events[i] = EventNode.Serdes(i, scriptable.Events[i], s, mapId, mapId.ToMapText(), mapping);
                }
            });
        }
Beispiel #3
0
    static void MapData(IAssetManager assets, string baseDir, AssetId[] dumpIds)
    {
        using var sw = Open(baseDir, MapInfoPath);
        for (int i = 100; i < 400; i++)
        {
            MapId id = MapId.From((Base.Map)i);
            if (dumpIds != null && !dumpIds.Contains(id))
            {
                continue;
            }

            IMapData map = assets.LoadMap(id);
            if (map == null)
            {
                continue;
            }

            sw.Write($"{i} {(Base.Map)i} {map.MapType} ");
            sw.Write($"{map.Width}x{map.Height} ");
            sw.Write($"Palette:{map.PaletteId} ({map.PaletteId.Id}) ");
            if (map is MapData2D map2d)
            {
                sw.Write($"FrameRate:{map2d.FrameRate} ");
                sw.Write($"TileSet:{map2d.TilesetId} ");
                sw.Write($"Flags:{map2d.Flags} ");
                sw.Write($"Sound?:{map2d.Sound} ");
            }

            LabyrinthData lab = null;
            if (map is MapData3D map3d)
            {
                sw.Write($"Flags: {map3d.Flags} ");
                sw.Write($"Labyrinth: {map3d.LabDataId} ");
                sw.Write($"Sound?:{map3d.AmbientSongId} ");
                lab = assets.LoadLabyrinthData(map3d.LabDataId);
            }

            sw.Write($"Song:{map.SongId} ({map.SongId.Id}) ");
            sw.WriteLine($"CombatBackground:{map.CombatBackgroundId} ({map.CombatBackgroundId.Id})");

            for (int j = 0; j < map.Npcs.Count; j++)
            {
                var npc = map.Npcs[j];
                if (npc == null)
                {
                    continue;
                }

                var wp     = npc.Waypoints.FirstOrDefault();
                var idText = npc.Id.ToString().PadLeft(15);

                sw.Write($"    Npc{j:D3}: {idText} ({npc.Id.Id:D3}) ");
                sw.Write($"X:{wp.X:D3} Y:{wp.Y:D3} ");
                sw.Write($"F{(int)npc.Flags:X2}:({npc.Flags}) ");
                sw.Write($"M:{npc.Movement} ");
                sw.Write($"S:{npc.Sound} ({npc.Sound}) ");
                switch (map.MapType)
                {
                case MapType.TwoD: sw.Write($"GR:{npc.SpriteOrGroup} "); break;

                case MapType.TwoDOutdoors: sw.Write($"KL:{npc.SpriteOrGroup} "); break;

                case MapType.ThreeD:
                    if (lab != null)
                    {
                        if (npc.SpriteOrGroup.Id >= lab.ObjectGroups.Count)
                        {
                            sw.Write($"InvalidObjGroup:{npc.SpriteOrGroup.Id}");
                        }
                        else
                        {
                            var objectData = lab.ObjectGroups[npc.SpriteOrGroup.Id];
                            sw.Write($"3D:{npc.SpriteOrGroup.Id}=(");
                            bool first = true;
                            foreach (var subObject in objectData.SubObjects)
                            {
                                if (subObject == null)
                                {
                                    continue;
                                }
                                if (!first)
                                {
                                    sw.Write(", ");
                                }
                                first = false;
                                var def = lab.Objects[subObject.ObjectInfoNumber];
                                sw.Write(def.SpriteId);
                            }

                            sw.Write(")");
                        }
                    }

                    break;
                }

                sw.WriteLine();
                if (npc.Chain != 0xffff)
                {
                    sw.WriteLine($"        EventChain: {npc.Chain}");
                    var formatter = new EventFormatter(assets.LoadString, id.ToMapText());
                    sw.WriteLine(formatter.FormatChain(npc.Node, 2));
                }
            }
            sw.WriteLine();
        }
    }